BC-33 hdu 5186
2015-03-15 11:24
821 查看
从现在起重拾BC吧……
完全不能理解为什么之前会WA掉…… 但是反正第一版好生复杂…… 是我的错……没有多动动脑子……
水题不解释……QAQ
完全不能理解为什么之前会WA掉…… 但是反正第一版好生复杂…… 是我的错……没有多动动脑子……
水题不解释……QAQ
#include <stdio.h> #include <string.h> int max(int a,int b) { return a>b?a:b; } int main() { int n,m; while(scanf("%d%d",&n,&m)!=EOF) { int i,j,k; char s[220]; int a[220],ans[220]; memset(a,0,sizeof(a)); memset(ans,0,sizeof(ans)); int mlen=0; for(i=0;i<n;i++) { scanf("%s",s); int len=strlen(s); for(j=len-1;j>=0;j--) { if(s[j]<='9'&&s[j]>='0') a[j]=s[j]-'0'; else a[j]=s[j]-'a'+10; ans[len-1-j]+=a[j]; if(ans[len-1-j]>=m) ans[len-1-j]%=m; } mlen=max(mlen,len); } int len; int flag=0; for(i=mlen-1;i>=0;i--) if(ans[i]!=0) {flag=1;len=i;break;} if(!flag) {printf("0\n");continue;} for(i=len;i>=0;i--) { if(ans[i]>9) printf("%c",ans[i]+'a'-10); else printf("%c",ans[i]+'0'); } printf("\n"); } return 0; }
相关文章推荐
- 【CUGBACM15级BC第33场 A】hdu 5186 zhx's submissions
- hdu 1179 Ollivanders: Makers of Fine Wands since 382 BC. (最大匹配)
- HDU 1179 Ollivanders: Makers of Fine Wands since 382 BC.(二分图匹配+匈牙利算法)
- 【CUGBACM15级BC第1场 A】hdu 4857 逃生
- HDU 5777/BC 85B domino
- 【CUGBACM15级BC第22场 A】hdu 5142 NPY and FFT
- HDU 4909 / BC 3C String
- HDU 5499/BC 59A SDOI
- hdu 4931 /BC 4A Happy Three Friends
- HDU 5631 Rikka with Graph(BC)
- HDU 5186 zhx's submissions 模拟水题
- HDU - 5190 - Go to movies && 5191 - Building Blocks (BC#34 A,B)
- HDU 1179 Ollivanders: Makers of Fine Wands since 382 BC. 二分图匹配
- 【CUGBACM15级BC第20场 A】hdu 5123 who is the best?
- 【CUGBACM15级BC第12场 A】【STL】hdu 5058 So easy
- HDU 5198 /BC 36A Strange Class
- 【CUGBACM15级BC第37场 A】hdu 5202 Rikka with string
- 【CUGBACM15级BC第1场 B】hdu 4858 项目管理
- 【CUGBACM15级BC第22场 C】hdu 5144 NPY and shot
- hdu 5672 String(BC——查找子串的个数 模拟)