BC#33
来源:互联网 发布:电力系统仿真软件比较 编辑:程序博客网 时间:2024/05/04 06:56
zhx's submissions
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 458 Accepted Submission(s): 116
Problem Description
As one of the most powerful brushes, zhx submits a lot of code on many oj and most of them got AC.
One day, zhx wants to count how many submissions he made onn ojs. He knows that on the ith oj, he made ai submissions. And what you should do is to add them up.
To make the problem more complex, zhx gives youn B−base numbers and you should also return a B−base number to him.
What's more, zhx is so naive that he doesn't carry a number while adding. That means, his answer to5+6 in 10−base is 1 . And he also asked you to calculate in his way.
One day, zhx wants to count how many submissions he made on
To make the problem more complex, zhx gives you
What's more, zhx is so naive that he doesn't carry a number while adding. That means, his answer to
Input
Multiply test cases(less than 1000 ). Seek EOF as the end of the file.
For each test, there are two integersn and B separated by a space. (1≤n≤100 , 2≤B≤36 )
Then come n lines. In each line there is aB−base number(may contain leading zeros). The digits are from 0 to 9 then from a to z (lowercase). The length of a number will not execeed 200.
For each test, there are two integers
Then come n lines. In each line there is a
Output
For each test case, output a single line indicating the answer in B−base (no leading zero).
Sample Input
2 3221 42333 16abbccd
Sample Output
123314
Source
BestCoder Round #33
#include <cstdio>#include <iostream>#include <cstring>#include <cmath>#include <algorithm>#include <string.h>#include <string>#include <vector>#include <queue>#define MEM(a,x) memset(a,x,sizeof a)#define eps 1e-8#define MOD 10009#define MAXN 10010#define INF 99999999#define ll __int64#define bug cout<<"here"<<endl#define fread freopen("ceshi.txt","r",stdin)#define fwrite freopen("out.txt","w",stdout)using namespace std;void read(int &x){ char ch; x=0; while(ch=getchar(),ch!=' '&&ch!='\n') { x=x*10+ch-'0'; }}char ch[210];int a[210];int main(){// fread; int n,b; while(scanf("%d%d",&n,&b)!=EOF) { MEM(a,0); while(n--) { scanf("%s",ch); int len=strlen(ch); for(int i=0;i<len;i++) { if(ch[i]>='0'&&ch[i]<='9') a[len-1-i]+=ch[i]-'0'; else a[len-1-i]+=ch[i]-'a'+10; } } int i; for(i=200;i>=0;i--) { a[i]%=b; if(a[i]) break; } if(i==-1) { printf("0\n"); continue; } for(;i>=0;i--) { a[i]%=b; if(a[i]<=9) printf("%d",a[i]); else printf("%c",a[i]-10+'a'); } puts(""); } return 0;}
zhx's contest
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 822 Accepted Submission(s): 270
Problem Description
As one of the most powerful brushes, zhx is required to give his juniors n problems.
zhx thinks theith problem's difficulty is i . He wants to arrange these problems in a beautiful way.
zhx defines a sequence{ai} beautiful if there is an i that matches two rules below:
1:a1..ai are monotone decreasing or monotone increasing.
2:ai..an are monotone decreasing or monotone increasing.
He wants you to tell him that how many permutations of problems are there if the sequence of the problems' difficulty is beautiful.
zhx knows that the answer may be very huge, and you only need to tell him the answer modulep .
zhx thinks the
zhx defines a sequence
1:
2:
He wants you to tell him that how many permutations of problems are there if the sequence of the problems' difficulty is beautiful.
zhx knows that the answer may be very huge, and you only need to tell him the answer module
Input
Multiply test cases(less than 1000 ). Seek EOF as the end of the file.
For each case, there are two integersn and p separated by a space in a line. (1≤n,p≤1018 )
For each case, there are two integers
Output
For each test case, output a single line indicating the answer.
Sample Input
2 2333 5
Sample Output
21HintIn the first case, both sequence {1, 2} and {2, 1} are legal.In the second case, sequence {1, 2, 3}, {1, 3, 2}, {2, 1, 3}, {2, 3, 1}, {3, 1, 2}, {3, 2, 1} are legal, so the answer is 6 mod 5 = 1
#include <cstdio>#include <iostream>#include <cstring>#include <cmath>#include <algorithm>#include <string.h>#include <string>#include <vector>#include <queue>#define MEM(a,x) memset(a,x,sizeof a)#define eps 1e-8#define MOD 10009#define MAXN 10010#define INF 99999999#define ll long long#define bug cout<<"here"<<endl#define fread freopen("ceshi.txt","r",stdin)#define fwrite freopen("out.txt","w",stdout)using namespace std;void read(int &x){ char ch; x=0; while(ch=getchar(),ch!=' '&&ch!='\n') { x=x*10+ch-'0'; }}ll n,p;ll mult(ll a,ll b){ ll res=0; while(b) { if(b&1) res=(res+a)%p; a=(a+a)%p; b>>=1; } return res%p;}ll power(ll a,ll b){ ll res=1; while(b) { if(b&1) res=mult(res,a); a=mult(a,a); b>>=1; } return res;}int main(){ //fread; while(scanf("%I64d%I64d",&n,&p)!=EOF) { if(n==1) { printf("%I64d\n",1LL%p); continue; } ll ans=power(2,n); ans-=2; ans%=p; ans+=p; ans%=p; printf("%I64d\n",ans); } return 0;}
0 0
- BC#33
- BC-33 hdu 5186
- bc
- bc
- bc
- bc
- BC
- BC
- BC右键
- BC #34
- BC 水水就好
- BC #38
- BC#47
- BC - Untitled
- BC LCS
- 【bc】计算器
- BC 81
- Oracle【BC】
- TOM猫的简单实现
- 初学Nodejs:nodejs在web应用中充当着什么样的角色?
- 每个程序员都应当知道的编译器优化知识
- bzoj1108 s-t平面图上的最大流
- 西电校园搜索引擎开发(3)--爬虫之主程
- BC#33
- Android:Service的非绑定式的创建和生命周期
- 如何使错误日志更加方便地排查问题
- 《C++编程》第一章第5题
- c#面向对象(三)----类的声明
- java并发--并发集合
- CSDN markdown 编辑器 第四篇 LaTex语法
- C#使用ServiceController控制windows服务
- Oracle体系结构(转载的学习用)