ccf 水题集
201612-2 工资计算
#include<iostream> using namespace std; int main() { int n; cin >> n; for(int i=1;i<=1000;i++) { int T=i*100; int cnt=T-3500; int fei=0; int ans=T-n; if(cnt<=0&&T==n) { cout << T << endl; break; } if(cnt<=0) continue; if(cnt<=1500) { fei+=cnt*0.03; if(fei==ans) { cout << T << endl; break; } continue; } if(cnt<=4500) { fei+=1500*0.03+(cnt-1500)*0.1; if(fei==ans) { cout << T << endl; break; } continue; } if(cnt<=9000) { fei+=1500*0.03+3000*0.1+(cnt-4500)*0.2; if(fei==ans) { cout << T <<endl; break; } continue; } if(cnt<=35000) { fei+=1500*0.03+3000*0.1+4500*0.2+(cnt-9000)*0.25; if(fei==ans) { cout << T << endl; break; } continue; } if(cnt<=55000) { fei+=1500*0.03+3000*0.1+4500*0.2+26000*0.25+(cnt-35000)*0.3; if(fei==ans) { cout << T << endl; break; } continue; } if(cnt<=80000) { fei+=1500*0.03+3000*0.1+4500*0.2+26000*0.25+20000*0.3+(cnt-55000)*0.35; if(fei==ans) { cout <<T <<endl; break; } continue; } if(cnt>80000) { fei+=1500*0.03+3000*0.1+4500*0.2+26000*0.25+20000*0.3+25000*0.35+(cnt-80000)*0.45; if(fei==ans) { cout << T << endl; break; } continue; } } return 0; }
画图
#include<iostream> using namespace std; int num[150][150]; int main() { int n; int a, b, c, d; cin >> n; for(int i=0;i<n;i++) { cin >> a >> b >> c >> d; if(a==c) c+=1; if(b==d) d+=1; for(int j=a;j<c;j++) { for(int k=b;k<d;k++) { num[j][k]=1; } } } int flag=0; for(int i=0;i<150;i++) { for(int j=0;j<150;j++) { if(num[i][j]) flag++; } } cout << flag << endl; return 0; }