1 条题解
-
0
C :
#include<stdio.h> int main(){ int i,j,n; while(scanf("%d",&n)!=EOF && n!=0){ int count=0; for(i=0;i<n;i++){ scanf("%d",&j); while(j>=100){ j=j-100; count++; } while(j>=50){ j=j-50; count++; } while(j>=10){ j=j-10; count++; } while(j>=5){ j=j-5; count++; } while(j>=2){ j=j-2; count++; } count=count+j; } printf("%d\n",count); } return 0; }
C++ :
#include<iostream> #include<string.h> using namespace std; int main() { int n, a[101],i,j,k; cin >> n; i = 0; k = n; while (n--) { cin >> a[i]; i++; } j = 0; for (i = 0; i < k; i++) { if (a[i] >= 100) { j =j+ a[i] / 100; a[i] = a[i] % 100; } if(a[i]>=50) { j = j+(a[i] / 50); a[i] = a[i] %50; } if (a[i] >= 10) { j = j + (a[i] /10); a[i] = a[i] % 10; } if (a[i] >= 5) { j = j + (a[i]/ 5); a[i] = a[i] % 5; } if (a[i] >= 2) { j = j + (a[i] /2); a[i] = a[i] % 2; } if (a[i] >= 1) { j = j + (a[i] / 1); a[i] = a[i] % 1; } }cout << j<<endl; return 0; }
- 1
信息
- ID
- 2678
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者