大数模余
来源:互联网 发布:程序编写软件 编辑:程序博客网 时间:2024/05/29 17:15
题目描述:
A lot of people have played fortune Test(or called RP Test) before. Let ’ s create a new Test below.
Suppose the worth of a=1, b=4,c=9 … and z=26^2. Then abc can describe as 149,and abd describe as
1416. As it is too large ,we take it mod 101 as ours fortune worth. S o abd has only 2 RP. Now I give you
a name, please tell me the worth of it.
输入
The first line of the input contains the number of test cases in the file. Each test case that follows
consists of one lines. each case contains only one string s specifying a person ’ s name, which only
contains lower-case .
输出
For each test case, print a line contains the answer.
样例输入
1
a
样例输出
1
A lot of people have played fortune Test(or called RP Test) before. Let ’ s create a new Test below.
Suppose the worth of a=1, b=4,c=9 … and z=26^2. Then abc can describe as 149,and abd describe as
1416. As it is too large ,we take it mod 101 as ours fortune worth. S o abd has only 2 RP. Now I give you
a name, please tell me the worth of it.
输入
The first line of the input contains the number of test cases in the file. Each test case that follows
consists of one lines. each case contains only one string s specifying a person ’ s name, which only
contains lower-case .
输出
For each test case, print a line contains the answer.
样例输入
1
a
样例输出
1
#include <iostream>#include <cstdio>#include <cstring>#include <stack>using namespace std;const int maxn = 10000;char str[maxn];int a[maxn];int T;void translate(){ stack<int> s; int point = 0; int len = strlen(str); int x; for(int i = 0; i<len; i++){ int mid = str[i]-'a'+1; int tmp = mid * mid; while(tmp) { ///把数值X分解并存入数组a中。 x = tmp%10; s.push(x); tmp = tmp/10; } int counter = (int)s.size(); for(int j=1; j<=counter; j++) { a[point++] = s.top(); s.pop(); } }}int work() { int ans = 0; for(int i = 0; a[i]>0; i++) { ans = (ans*10+a[i])%101; } return ans;}int main(){ scanf("%d", &T); while(T--) { scanf("%s", str); getchar(); translate(); int res = work(); printf("%d\n", res); memset(a, 0, sizeof(a)); memset(str, 0, sizeof(str)); } return 0;}
- 大数模余
- poj 2635 大数模运算(内有打素数表的模板,大树求余分解公式)
- hdu 2035 大数模
- poj2635 大数模运算
- 大数模小数
- 大数模运算相关资料
- poj-1845(大数模运算)
- 数模
- 数模
- HDU 1212 Big Number 大数模小数
- 【模逆元】大组合数模运算 _CDTemplate
- 〖数学算法〗大数模幂运算快速算法
- 〖数学算法〗大数模幂运算快速算法
- 大组合数模100W以内任意整数
- SABER 最强大的数模混合信号仿真软件
- POJ 1845 Sumdiv(因子和 大数模 费马小定理)
- sdut3260——Single Round Math(大数模)
- 大整数的加减乘除求余
- GDB查看变量
- Get请求传值乱码问题解决
- 适配器模式
- GDB使用方法简介
- poj - 3070 - Fibonacci(矩阵快速幂)
- 大数模余
- My Tower defence game prototype
- 杭电ACM1095解决A+B问题
- Android uses-permission
- first contest in this season
- android Theme使用总结
- objective-c 类的声明 以及实例调用
- 成本加酬金合同
- ORA-12560产生原因