1 solutions
-
0
C++ :
#include<iostream> using namespace std; int main() { int a[12],m=300,sheng=0,z,g=0,c=0,y; for(int i=1;i<=12;i++) { cin>>a[i]; z=sheng+m;//月初总钱 if((z-a[i])>=0) { c+=(z-a[i])/100*100; sheng=(z-a[i])-(z-a[i])/100*100; } if((z-a[i])<0) { cout<<-i<<endl;break; } if(i==12){ y=c+c/5+sheng; cout<<y;break; } } return 0; }Pascal :
var a:array[1..12]of integer; I,total,p:integer; begin {assign(input,'save.in'); reset(input); assign(output, 'save.out'); rewrite(output);} total:=0; for i:=1 to 12 do readln(a[i]); for i:=1 to 12 do begin total:=total+(300-a[i]); if total<0 then begin write('-',i); halt; end; if total>=100 then begin p:=p+total div 100; total:=total mod 100; end; end; writeln(p*120+total); {close(input); close(output);} end.
- 1
Information
- ID
- 17913
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By