C_1003

来源:互联网 发布:大连网络咨询男科 编辑:程序博客网 时间:2024/05/16 15:50
#include <iostream>#include <math.h>using namespace std;/*COJ_1003*/int main(void){int T;cin>>T;while(T--){int d, n, score,lv;n=score=lv=0;cin>>d;while(d--){char b;cin>>b;if(b=='0'){score += n<6 ? n*(n+1)/2 : n/5*15+(n%5*(n%5+1)/2);   //或逢5清零也行n=0;}else if(d>1)++n;else {++n; score += n<6 ? n*(n+1)/2 : n/5*15+(n%5*(n%5+1)/2);}}lv = score<75 ? floor(0.1*(score+5)) : 8; //floor函数在math.h里,好吧,我承认我不知道cout<<lv<<endl;}return 0;}
/*差不多啦~第一次写,以后再修改啦,应该有修改博文的功能吧*/
/*WA......*/
#include <iostream>//#include <math.h>using namespace std;/*COJ_1003*/int main(void){int T;cin>>T;while(T--){int d, n, score;n=score=0;cin>>d;while(d--){char b;cin>>b;if(b=='1'){++n;if(n==5) {n=0; score+=15;}  //逢5清零if(d==0) score += (n*(n+1)/2);//非逢5清零((n<6) ? (n*(n+1)/2) : (n/5*15+(n%5*(n%5+1)/2)));}//上面一行不是d==0!!!d--已经减了1了!else{if(n==0) continue;score += (n*(n+1)/2);  //((n<6) ? (n*(n+1)/2) : (n/5*15+(n%5*(n%5+1)/2)));n=0; //n%2?(n+1)/2*n:n/2*(n+1)}}//lv = (score<75) ? (score/10) : 8;cout<<((score+5)/10)<<endl<<score<<endl; //cout<<(score>=75?8:((score+5)/10))<<endl;因为忘了这个,居然让我浪费了那么多时间!!仔细点!}return 0;}

0 0
原创粉丝点击