目录

  • 题目:
    • Input
    • Output
    • Example
    • 解析
    • AC代码

题目:

C. Carrying Conundrum
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
Alice has just learned addition. However, she hasn’t learned the concept of “carrying” fully — instead of carrying to the next column, she carries to the column two columns to the left.

For example, the regular way to evaluate the sum 2039+2976 would be as shown:

However, Alice evaluates it as shown:

In particular, this is what she does:

add 9 and 6 to make 15, and carry the 1 to the column two columns to the left, i. e. to the column “0 9”;
add 3 and 7 to make 10 and carry the 1 to the column two columns to the left, i. e. to the column “2 2”;
add 1, 0, and 9 to make 10 and carry the 1 to the column two columns to the left, i. e. to the column above the plus sign;
add 1, 2 and 2 to make 5;
add 1 to make 1.
Thus, she ends up with the incorrect result of 15005.
Alice comes up to Bob and says that she has added two numbers to get a result of n. However, Bob knows that Alice adds in her own way. Help Bob find the number of ordered pairs of positive integers such that when Alice adds them, she will get a result of n. Note that pairs (a,b) and (b,a) are considered different if a≠b.

Input

The input consists of multiple test cases. The first line contains an integer t (1≤t≤1000) — the number of test cases. The description of the test cases follows.

The only line of each test case contains an integer n (2≤n≤109) — the number Alice shows Bob.

Output

For each test case, output one integer — the number of ordered pairs of positive integers such that when Alice adds them, she will get a result of n.

Example

input

5
100
12
8
2021
10000

output

9
4
7
44
99

解析

会发现,奇数位只会进位到奇数位,偶数位只会进位到偶数位。即:相邻的奇数位之间满足十进制关系(偶数位同理)
例:12的奇数位为2,偶数位为1;
2可以由0+2 1+1 2+0获得
1可以由0+1 1+0获得
2*3即为总的方案数,最后需要减去奇偶数位和全为0的情况

AC代码

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
using namespace std;int main()
{int t;cin >> t;int a;while (t--){cin>>a;int temp=a;int num=1;//位数while(temp/10!=0){num++;temp/=10;}num++;int ji=0,ou=0;int num1=1,num2=1;for(int i=1;i<=num;i++){if(i%2==0)//偶数位{ou+=a%10*num1;num1*=10;}else//奇数位{ji+=a%10*num2;num2*=10;}a/=10;}ji++,ou++;cout<<ji*ou-2<<endl;}return 0;
}
  • 新手小白,如有问题望斧正!

Codeforces Round #742 (Div. 2) C. Carrying Conundrum相关推荐

  1. Codeforces Round #742 (Div. 2) C. Carrying Conundrum(思维)

    题目链接 题目大意: 定义了一种新的加法进位的方式,给你一个数 nnn ,计算有多少组两个数之和等于 nnn . 解题思路: 将 nnn 的奇偶位分开,变成两个数 num1,num2num1,num2 ...

  2. Codeforces Round #742 (Div. 2) F. One-Four Overload 构造 + 二分图染色

    传送门 文章目录 题意: 思路: 题意: 给你一个n∗mn*mn∗m的矩形,包含...和XXX,你有两种颜色,你需要给...染色使得每个XXX上下左右相邻的...其两种颜色个数相同,输出一种合法方案. ...

  3. Codeforces Round #742 (Div. 2) B、C 题解

    Codeforces Round 742 B. MEXor Mixup 题意 有一个数组,输入两个数a,b,a代表这个数组之外的最小非负整数,b代表这个数组的异或值,问你该数组的最小长度. 思路 首先 ...

  4. Codeforces Round #742 (Div. 2)

    题目 题解链接 难度 主要算法 A. Domino Disaster A. Domino Disaster 800 模拟 B. MEXor Mixup B. MEXor Mixup 1000 思维 C ...

  5. Codeforces Round #742 (Div. 2) E. Non-Decreasing Dilemma (线段树维护区间连续问题)

    题意: 操作1:把x位置的数字修改成y. 操作2:查询[l,r]之间不下降序列的个数. 题解: 线段树维护区间和问题 (这是套路,想不到只能说做题少别打我) . 用五个变量进行维护. sum区间总个数 ...

  6. Codeforces Round #742 (Div. 2) 个人题解

    A. Domino Disaster 2分钟签到 #include <bits/stdc++.h> #define fors(i, a, b) for(int i = (a); i < ...

  7. Codeforces Round #742 (Div. 2) D. Expression Evaluation Error(思维 + 贪心)

    链接 D. Expression Evaluation Error 题意 给出一个十进制数 s s s,分成 n n n 个数,这 n n n 个数十进制和为 s s s,要让 n n n个数十一进制 ...

  8. Codeforces Round #506 (Div. 3)

    Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...

  9. Codeforces Round #563 (Div. 2)/CF1174

    Codeforces Round #563 (Div. 2)/CF1174 CF1174A Ehab Fails to Be Thanos 其实就是要\(\sum\limits_{i=1}^n a_i ...

最新文章

  1. MFC的类层次结构图
  2. C#, CLR, and .NET Framework versions
  3. server2008r2/2012R2遠程桌面-企业协议号
  4. 在终端(Terminal)中用颜色显示不同类型文件
  5. java 大数四则运算_大数四则运算java(转)
  6. 设置代理_PC客户端爬虫,这样设置代理就对了
  7. laravel数组转换为字符串_LeetCode刷题实战108:将有序数组转换为二叉搜索树
  8. java给方法参数赋值_java方法参数的赋值问题实例源码介绍
  9. [FFmpeg] 拼接音频
  10. 计算机基础操作知识带答案,计算机应用基础知识试题带答案
  11. python多级网址爬取_『采集超市』添加多级网址之手动填写链接地址规则
  12. linux下RabbitMQ的配置和安装
  13. transition过渡的基本使用
  14. 最全的关于硬件测试的解读
  15. 【BZOJ4399】—膜法少女LJJ(线段树合并)
  16. mac 修改文件权限为777可读可写可执行
  17. JVM系列(十七):字节码指令集
  18. 面试时如何用英语自我介绍?
  19. vue 视频播放插件vue-video-player自定义样式、自动播放设置、设置一开始全屏播放视频
  20. 查询时报错The error may involve defaultParameterMap ### The error occurred while setting parameters

热门文章

  1. 用Powerpoint (PPT)制作并导出矢量图、高分辨率图
  2. 31道Java面试题,免费mysql服务器
  3. 手把手教你打造全宇宙最强 Firefox 浏览器
  4. 分布式ID之snowflake
  5. win7修复计算机消失,win7系统引导文件丢失的修复妙招
  6. python练习题-运算符和变量练习作业题
  7. Qt:创建文件夹QDir
  8. Windows 10(Office 2019)下安装mathtype 6.9/7.4以及相关冲突问题解决
  9. npm插件开发-Vue插件
  10. 视频融合云服务EasyCVR平台部署在云服务器中的配置关键点