A. 学姐的桌面 2014新生暑假个人排位赛01
题目描写叙述
学姐在增加集训队之后。学习了使用ubuntu系统来做题,可是没有了360电脑管家,学姐再也没办法看到她的飞速电脑开机究竟虐了全国多少人。作为一个电脑高手。学姐花了几分钟黑到了360的数据库拿到了全国360用户的开机时间,如今学姐想自己算算究竟打败了百分之多少的人?
输入格式
输入有多组数据。
首先给出数据组数
当中
输出格式
每组数据一行,输出学姐打败了全国百分之多少的用户,精确到小数点后两位。
输入例子
1
5 3
1 1 2 2 3
输出例子
80.00%
这题数据有问题。,,越大的反而越快#include <iostream> #include <cstdio> #include <algorithm> using namespace std; int num[111111]; int main() { #ifndef ONLINE_JUDGE freopen("D:/in.txt","r",stdin); //freopen(); #endif int T; scanf("%d",&T); while(T--) { int n,s; scanf("%d%d",&n,&s); for(int i=1;i<=n;i++) { scanf("%d",num+i); } sort(num+1,num+1+n); int i=1; for(i=1;i<=n;i++) { if(num[i]>=s) break; } //cout<<"i::"<<i<<endl; double ans=(i-1)*1.0/n; printf("%.2f",ans*100); cout<<"% "; } return 0; }
B. 学姐去学车 2014新生暑假个人排位赛01
题目描写叙述
趁着放假。学姐去学车好带学弟去兜风。可是学车真的非常辛苦,每天五点半就要起床赶班车,可是学姐的教练更辛苦,他们要同样的时间到并且日日如此。于是温和的学姐关切的问了他们的歇息情况,教练告诉她。他们两个人倒班教学姐,每一个教练每上
输入格式
输入開始为数据组数
输出格式
对于每一个询问
输入例子
1
5 3
3
6
9
13
输出例子
2
1
2
签到题,一炮,逻辑题。命名挺优雅#include <iostream> #include <cstdio> #include <algorithm> using namespace std; int num[111111]; int main() { #ifndef ONLINE_JUDGE freopen("D:/in.txt","r",stdin); //freopen(); #endif int T; scanf("%d",&T); while(T--) { int n,m; scanf("%d%d",&n,&m); int oneZero=n+1; int oneShi=m+n+1; int relativeShi_one=oneShi-oneZero; int twoZero=m; int twoShi=n+1; int relativeShi_two=twoShi-twoZero; int len=n+1; int quesnum;scanf("%d",&quesnum); int ques; for(int i=1;i<=quesnum;i++) { scanf("%d",&ques); if(ques<=n) { printf("1 "); continue; } int inONE=(ques-n-1)%len; int inTWO=(ques-m)%len; if(inONE==0) printf("2 "); else if(inONE<relativeShi_one) printf("2 "); else printf("1 "); } } return 0; }
C. 学姐的学弟 2014新生暑假个人排位赛01
题目描写叙述
学姐正在写作业。可是她写着写着就開始想学弟,走神的她就開始在纸上画圈圈。这时学弟突然出现了,好奇的学弟问学姐在做什么,惊慌之下,学姐随口说想算一下这些圆覆盖的面积为多少。学弟顿时很敬仰学姐。可是学姐突然意识到自己不会做,为了自己能给学弟留下好印象。她来求助你帮她算出来这些圆覆盖的面积。
为了简化问题,我们如果全部圆的半径都为1。
输入格式
输入有多组数据。开头为一个整数
输出格式
输出一个数,表示面积并,精确到小数点后五位。
输入例子
1
2
1 1
2 1
输出例子
5.05482
这题,初始是全零的整点阵,把圆心都标记为1,然后,面积仅仅有3种情况你懂得,遍历全部4个点组成的格子,看4个点的圆心分布情况#include <iostream> #include <cstdio> #include <cmath> #include <cstdlib> #include <cmath> #include <algorithm> #include <stack> #include <vector> #include <cstring> const double pi=acos(-1.0); using namespace std; int g[111][111]; int main() { int T;scanf("%d",&T); double sq1=0.25*pi; double sq2=pi/6+sqrt(3)/4; while(T--) { memset(g,0,sizeof(g)); int num;scanf("%d",&num); for(int i=1;i<=num;i++) { int x,y;scanf("%d%d",&x,&y); g[x][y]=1; } double ans=0; for(int i=0;i<=100;i++) { for(int j=0;j<=100;j++) { double tttt=ans; int ss=g[i][j]+g[i+1][j]+g[i][j+1]+g[i+1][j+1]; if(ss==1) { ans+=sq1; } else if(ss>2) { ans+=1; } else if(ss==2&&((g[i][j]==1&&g[i+1][j+1]==1)||(g[i][j+1]==1&&g[i+1][j]==1))) { ans+=1; } else if(ss==2) { ans+=sq2; } } } printf("%.5f ",ans); } return 0; }
D. BLOCKS 2014新生暑假个人排位赛01
题目描写叙述
给定一个
输入格式
有多组数据。EOF结束。
输出格式
每行相应一个answer
输入例子
6 8
.....#.#
##.....#
##.....#
.......#
#......#
#..#...#
6 8
.....#.#
##.....#
###...##
.......#
##.....#
#..#...#
输出例子
There are 5 ships.
So Sad
听贺爷说了个神方法#include <iostream> #include <cstdio> #include <cmath> #include <cstdlib> #include <cmath> #include <algorithm> #include <stack> #include <vector> #include <cstring> using namespace std; #define N 111111<div class="line number6 index5 alt1"><code class="cpp preprocessor">#include <iostream></code></div><div class="line number7 index6 alt2"><code class="cpp preprocessor">#include <cstdio></code></div><div class="line number8 index7 alt1"><code class="cpp preprocessor">#include <cmath></code></div><div class="line number9 index8 alt2"><code class="cpp preprocessor">#include <cstdlib></code></div><div class="line number10 index9 alt1"><code class="cpp preprocessor">#include <cmath></code></div><div class="line number11 index10 alt2"><code class="cpp preprocessor">#include <algorithm></code></div><div class="line number12 index11 alt1"><code class="cpp preprocessor">#include <stack></code></div><div class="line number13 index12 alt2"><code class="cpp preprocessor">#include <vector></code></div><div class="line number14 index13 alt1"><code class="cpp preprocessor">#include <cstring></code></div><div class="line number15 index14 alt2"><code class="cpp keyword bold">using</code> <code class="cpp keyword bold">namespace</code> <code class="cpp plain">std;</code></div><div class="line number16 index15 alt1"><code class="cpp preprocessor">#define N 111111</code></div><div class="line number17 index16 alt2"><code class="cpp color1 bold">char</code> <code class="cpp plain">g[1111][1111];</code></div><div class="line number18 index17 alt1"><code class="cpp color1 bold">int</code> <code class="cpp plain">main()</code></div><div class="line number19 index18 alt2"><code class="cpp plain">{</code></div><div class="line number20 index19 alt1"><code class="cpp spaces"> </code><code class="cpp color1 bold">int</code> <code class="cpp plain">n,m;</code></div><div class="line number21 index20 alt2"><code class="cpp spaces"> </code><code class="cpp keyword bold">while</code><code class="cpp plain">(</code><code class="cpp functions bold">scanf</code><code class="cpp plain">(</code><code class="cpp string">"%d%d"</code><code class="cpp plain">,&n,&m)!=EOF)</code></div><div class="line number22 index21 alt1"><code class="cpp spaces"> </code><code class="cpp plain">{</code></div><div class="line number23 index22 alt2"><code class="cpp spaces"> </code><code class="cpp keyword bold">for</code><code class="cpp plain">(</code><code class="cpp color1 bold">int</code> <code class="cpp plain">i=0;i<n;i++)</code></div><div class="line number24 index23 alt1"><code class="cpp spaces"> </code><code class="cpp plain">{</code></div><div class="line number25 index24 alt2"><code class="cpp spaces"> </code><code class="cpp functions bold">scanf</code><code class="cpp plain">(</code><code class="cpp string">"%s"</code><code class="cpp plain">,g[i]);</code></div><div class="line number26 index25 alt1"><code class="cpp spaces"> </code><code class="cpp plain">}</code></div><div class="line number27 index26 alt2"><code class="cpp spaces"> </code><code class="cpp color1 bold">bool</code> <code class="cpp plain">isout=</code><code class="cpp keyword bold">false</code><code class="cpp plain">;</code></div><div class="line number28 index27 alt1"><code class="cpp spaces"> </code><code class="cpp keyword bold">for</code><code class="cpp plain">(</code><code class="cpp color1 bold">int</code> <code class="cpp plain">i=0;i<n;i++)</code></div><div class="line number29 index28 alt2"><code class="cpp spaces"> </code><code class="cpp plain">{</code></div><div class="line number30 index29 alt1"><code class="cpp spaces"> </code><code class="cpp keyword bold">for</code><code class="cpp plain">(</code><code class="cpp color1 bold">int</code> <code class="cpp plain">j=0;j<m;j++)</code></div><div class="line number31 index30 alt2"><code class="cpp spaces"> </code><code class="cpp plain">{</code></div><div class="line number32 index31 alt1"><code class="cpp spaces"> </code><code class="cpp keyword bold">if</code><code class="cpp plain">(g[i][j]==</code><code class="cpp string">'.'</code><code class="cpp plain">)</code></div><div class="line number33 index32 alt2"><code class="cpp spaces"> </code><code class="cpp plain">{</code></div><div class="line number34 index33 alt1"><code class="cpp spaces"> </code><code class="cpp keyword bold">if</code><code class="cpp plain">((g[i-1][j]==</code><code class="cpp string">'#'</code><code class="cpp plain">&&g[i-1][j-1]==</code><code class="cpp string">'#'</code><code class="cpp plain">&&g[i][j-1]==</code><code class="cpp string">'#'</code><code class="cpp plain">)||</code></div><div class="line number35 index34 alt2"><code class="cpp spaces"> </code><code class="cpp plain">(g[i+1][j]==</code><code class="cpp string">'#'</code><code class="cpp plain">&&g[i+1][j-1]==</code><code class="cpp string">'#'</code><code class="cpp plain">&&g[i][j-1]==</code><code class="cpp string">'#'</code><code class="cpp plain">)||</code></div><div class="line number36 index35 alt1"><code class="cpp spaces"> </code><code class="cpp plain">(g[i][j+1]==</code><code class="cpp string">'#'</code><code class="cpp plain">&&g[i+1][j]==</code><code class="cpp string">'#'</code><code class="cpp plain">&&g[i+1][j+1]==</code><code class="cpp string">'#'</code><code class="cpp plain">)||</code></div><div class="line number37 index36 alt2"><code class="cpp spaces"> </code><code class="cpp plain">(g[i-1][j]==</code><code class="cpp string">'#'</code><code class="cpp plain">&&g[i-1][j+1]==</code><code class="cpp string">'#'</code><code class="cpp plain">&&g[i][j+1]==</code><code class="cpp string">'#'</code><code class="cpp plain">))</code></div><div class="line number38 index37 alt1"><code class="cpp spaces"> </code><code class="cpp plain">{</code></div><div class="line number39 index38 alt2"><code class="cpp spaces"> </code><code class="cpp functions bold">printf</code><code class="cpp plain">(</code><code class="cpp string">"So Sad "</code><code class="cpp plain">);</code></div><div class="line number40 index39 alt1"><code class="cpp spaces"> </code><code class="cpp plain">isout=</code><code class="cpp keyword bold">true</code><code class="cpp plain">;</code></div><div class="line number41 index40 alt2"><code class="cpp spaces"> </code><code class="cpp keyword bold">break</code><code class="cpp plain">;</code></div><div class="line number42 index41 alt1"><code class="cpp spaces"> </code><code class="cpp plain">}</code></div><div class="line number43 index42 alt2"><code class="cpp spaces"> </code><code class="cpp plain">}</code></div><div class="line number44 index43 alt1"><code class="cpp spaces"> </code><code class="cpp plain">}</code></div><div class="line number45 index44 alt2"><code class="cpp spaces"> </code><code class="cpp keyword bold">if</code><code class="cpp plain">(isout)</code></div><div class="line number46 index45 alt1"><code class="cpp spaces"> </code><code class="cpp keyword bold">break</code><code class="cpp plain">;</code></div><div class="line number47 index46 alt2"><code class="cpp spaces"> </code><code class="cpp plain">}</code></div><div class="line number48 index47 alt1"><code class="cpp spaces"> </code><code class="cpp keyword bold">if</code><code class="cpp plain">(isout)</code></div><div class="line number49 index48 alt2"><code class="cpp spaces"> </code><code class="cpp keyword bold">continue</code><code class="cpp plain">;</code></div><div class="line number50 index49 alt1"><code class="cpp spaces"> </code><code class="cpp color1 bold">int</code> <code class="cpp plain">countn=0;</code></div><div class="line number51 index50 alt2"><code class="cpp spaces"> </code><code class="cpp keyword bold">for</code><code class="cpp plain">(</code><code class="cpp color1 bold">int</code> <code class="cpp plain">i=0;i<n;i++)</code></div><div class="line number52 index51 alt1"><code class="cpp spaces"> </code><code class="cpp plain">{</code></div><div class="line number53 index52 alt2"><code class="cpp spaces"> </code><code class="cpp keyword bold">for</code><code class="cpp plain">(</code><code class="cpp color1 bold">int</code> <code class="cpp plain">j=0;j<m;j++)</code></div><div class="line number54 index53 alt1"><code class="cpp spaces"> </code><code class="cpp plain">{</code></div><div class="line number55 index54 alt2"><code class="cpp spaces"> </code><code class="cpp keyword bold">if</code><code class="cpp plain">(g[i][j]==</code><code class="cpp string">'#'</code><code class="cpp plain">)</code></div><div class="line number56 index55 alt1"><code class="cpp spaces"> </code><code class="cpp plain">{</code></div><div class="line number57 index56 alt2"><code class="cpp spaces"> </code><code class="cpp keyword bold">if</code><code class="cpp plain">(g[i-1][j]!=</code><code class="cpp string">'#'</code><code class="cpp plain">&&g[i][j-1]!=</code><code class="cpp string">'#'</code><code class="cpp plain">)</code></div><div class="line number58 index57 alt1"><code class="cpp spaces"> </code><code class="cpp plain">{</code></div><div class="line number59 index58 alt2"><code class="cpp spaces"> </code><code class="cpp plain">countn++; </code></div><div class="line number60 index59 alt1"><code class="cpp spaces"> </code><code class="cpp plain">}</code></div><div class="line number61 index60 alt2"><code class="cpp spaces"> </code><code class="cpp plain">}</code></div><div class="line number62 index61 alt1"><code class="cpp spaces"> </code><code class="cpp plain">}</code></div><div class="line number63 index62 alt2"><code class="cpp spaces"> </code><code class="cpp plain">}</code></div><div class="line number64 index63 alt1"><code class="cpp spaces"> </code><code class="cpp functions bold">printf</code><code class="cpp plain">(</code><code class="cpp string">"There are %d ships. "</code><code class="cpp plain">,countn);</code></div><div class="line number65 index64 alt2"><code class="cpp spaces"> </code><code class="cpp plain">}</code></div><div class="line number66 index65 alt1"><code class="cpp spaces"> </code><code class="cpp keyword bold">return</code> <code class="cpp plain">0;</code></div><div class="line number67 index66 alt2"><code class="cpp plain">}</code></div> char g[1111][1111]; int main() { int n,m; while(scanf("%d%d",&n,&m)!=EOF) { for(int i=0;i<n;i++) { scanf("%s",g[i]); } bool isout=false; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { if(g[i][j]=='.') { if((g[i-1][j]=='#'&&g[i-1][j-1]=='#'&&g[i][j-1]=='#')|| (g[i+1][j]=='#'&&g[i+1][j-1]=='#'&&g[i][j-1]=='#')|| (g[i][j+1]=='#'&&g[i+1][j]=='#'&&g[i+1][j+1]=='#')|| (g[i-1][j]=='#'&&g[i-1][j+1]=='#'&&g[i][j+1]=='#')) { printf("So Sad "); isout=true; break; } } } if(isout) break; } if(isout) continue; int countn=0; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { if(g[i][j]=='#') { if(g[i-1][j]!='#'&&g[i][j-1]!='#') { countn++; } } } } printf("There are %d ships. ",countn); } return 0; }
E. 数的关系 2014新生暑假个人排位赛01
题目描写叙述
用关系“<”和“=”将3个数A、B和C依序排列时有13种不同的序关系:
如今输入数字的个数。要求你给出上述关系的数目。
数的个数不大于100
输入格式
多组数据。EOF结束
每行一个输入
输出格式
对于每一个输入,输出一行,即相应答案
输入例子
3
输出例子
13
#include <iostream> #include <cstdio> #include <cmath> #include <cstdlib> #include <cmath> #include <algorithm> #include <stack> #include <vector> #include <cstring> using namespace std; class BigInteger { public: int num[100]; int maxlenn; int len; BigInteger() { maxlenn=300; len=0; memset(num,0,sizeof(num)); } BigInteger(char* ss) { maxlenn=300; len=0; memset(num,0,sizeof(num)); int& i=this->len; int lenofss=strlen(ss); char s[10]={0}; for(i=0;lenofss/4;lenofss-=4) { strncpy(s,ss+lenofss-4,4); this->num[i++]=atoi(s); } if(lenofss) { memset(s,0,sizeof(s)); strncpy(s,ss,lenofss); this->num[i++]=atoi(s); } } BigInteger(int s) { maxlenn=300; len=0; memset(num,0,sizeof(num)); while(s>10000) { num[len++]=s%10000; s/=10000; } if(s) { num[len++]=s; } } void Print() { int i; printf("%d",num[len-1]); for(i=this->len-2;i>=0;i--) { printf("%04d",this->num[i]); } printf(" "); } BigInteger Times(BigInteger sec)//该数本身没有变化,仅仅是返回了结果 { int i,j,jw; BigInteger ans; for(i=0;i<len;i++) { jw=0; ans.len=i; for(j=0;j<sec.len;j++) { jw+=this->num[i]*sec.num[j]+ans.num[ans.len]; ans.num[ans.len++]=jw%10000; jw/=10000; } while(jw) { jw+=ans.num[ans.len]; ans.num[ans.len++]=jw%10000; jw/=10000; } } return ans; } BigInteger plusone() { int i=0; do { num[i]++; num[i+1]+=num[i]/10000; num[i]%=10000; i++; }while(num[i]<9999); return *this; } BigInteger operator+(const BigInteger& sec) { bool isUp=false; BigInteger tmp=*this; int maxn=tmp.len>sec.len?tmp.len:sec.len; for(int i=0;i<maxn;i++) { /*if(isUp) { tmp.num[i]++; if(tmp.num[i]>=10000) { tmp.num[i]=0; isUp=true; } }*/ if(tmp.num[i]+sec.num[i]<=9999) { tmp.num[i]+=sec.num[i]; if(isUp) { tmp.num[i]++; isUp=false; if(tmp.num[i]==10000) { tmp.num[i]=0; isUp=true; } } } else { tmp.num[i]=tmp.num[i]+sec.num[i]-10000; if(isUp) { tmp.num[i]++; } isUp=true; } } if(isUp) tmp.num[maxn]=1; if(tmp.num[maxn]!=0) tmp.len++; else tmp.len=maxn; return tmp; } BigInteger operator-(const BigInteger& sec)//big-small { bool isBorrow=false; BigInteger tmp=*this; for(int i=0;i<this->len;i++) { if(isBorrow) { tmp.num[i]-=1; if(tmp.num[i]<0) tmp.num[i]=9999; } if(tmp.num[i]<sec.num[i]) { tmp.num[i]=tmp.num[i]+10000-sec.num[i]; isBorrow=true; } else { tmp.num[i]-=sec.num[i]; isBorrow=false; } } int i=0; for(i=maxlenn-1;;i--) { if(tmp.num[i]!=0) break; } if(i==0) tmp.len=1; else tmp.len=i+1; return tmp; } BigInteger operator*(const BigInteger sec) { return this->Times(sec); } int operator/(const BigInteger& sec)//big/small { BigInteger tmp=*this; int ans=0; while(tmp>=sec) { tmp=tmp-sec; ans++; } return ans; } BigInteger operator%(const BigInteger& sec) { BigInteger tmp=*this; while(tmp>=sec) { tmp=tmp-sec; } return tmp; } BigInteger& operator++() { this->plusone(); return *this; } bool operator<=(const BigInteger& sec) { if(len<sec.len) return true; for(int i=len-1;i>=0;i--) { if(num[i]>sec.num[i]) return false; } return true; } bool operator>=(const BigInteger& sec) { if(len>sec.len) return true; for(int i=len-1;i>=0;i--) { if(num[i]<sec.num[i]) return false; } return true; } bool operator==(const BigInteger& sec) { if(len!=sec.len) return false; for(int i=len-1;i>=0;i--) { if(num[i]!=sec.num[i]) return false; } return true; } bool operator==(const int& sec) { if(len!=1) return false; if(num[0]==sec) return true; else return false; } bool operator<(const BigInteger& sec) { if(len<sec.len) return true; for(int i=len-1;i>=0;i--) { if(num[i]>sec.num[i]) return false; else if(num[i]<sec.num[i]) return true; } return false; } bool operator>(const BigInteger& sec) { if(len>sec.len) return true; for(int i=len-1;i>=0;i--) { if(num[i]<sec.num[i]) return false; else if(num[i]>sec.num[i]) return true; } return false; } bool operator!=(const BigInteger& sec) { if(len!=sec.len) return true; for(int i=len-1;i>=0;i--) { if(num[i]!=sec.num[i]) return true; } return false; } /*BigInteger GCD(const BigInteger& first,const BigInteger& sec) { return first%sec==0?sec:GCD(sec,first%sec); } BigInteger LCM(const BigInteger& first,const BigInteger& sec) { return first/GCD(first,sec)*sec; }*/ }; #define N 111111 BigInteger dp[111][111]; int main() { BigInteger ZERO("0"); for(int i=0;i<=110;i++) { for(int j=0;j<=110;j++) { dp[i][j]=ZERO; } } dp[2][1]=BigInteger(1); dp[2][2]=BigInteger(2); for(int i=3;i<=100;i++) { for(int j=1;j<=i;j++) { char tmpchar[11]; sprintf(tmpchar,"%d",j); /*if(i==7&&j==6) { cout<<"1::";(BigInteger(tmpchar)*dp[i-1][j]).Print(); cout<<"2::";(BigInteger(tmpchar)*dp[i-1][j-1]).Print(); cout<<"dp76::";dp[7][6].Print(); }*/ dp[i][j]=dp[i][j]+BigInteger(tmpchar)*dp[i-1][j]; dp[i][j]=dp[i][j]+BigInteger(tmpchar)*dp[i-1][j-1]; /*if(i==7&&j==6) { cout<<"dp76::";dp[7][6].Print(); }*/ } } int ques; while(scanf("%d",&ques)!=EOF) { if(ques==1) { printf("1 "); continue; } BigInteger ans("0"); for(int i=1;i<=ques;i++) { /*if(ques==7) { cout<<"ans::";ans.Print(); cout<<"dp::"<<"ques::"<<ques<<"i::"<<i<<' ';dp[ques][i].Print(); }*/ ans=ans+dp[ques][i]; } ans.Print(); } return 0; }