上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 26 下一页
摘要: A:超级大水题,不解释:代码: 1 #include 2 #include 3 using namespace std; 4 int a,b; 5 int main() 6 { 7 int n,m,ma=0,mi=9999999,mb=9999999; 8 cin>>n>>m; 9 for(int i=0; i>a;12 if(a>ma)ma=a;13 if(a>b;18 if(mb>b)mb=b;19 }20 if(mi*2>ma)ma=mi*2;21 if(ma>=mb)cout 2 #incl... 阅读全文
posted @ 2013-10-15 18:14 Yours1103 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 只会做三个题;A:简单题,不解释: 1 #include 2 using namespace std; 3 4 int k,d; 5 6 int main() 7 { 8 scanf("%d%d",&k,&d); 9 if(d==0)10 {11 if(k>1)puts("No solution");12 else puts("0");13 }14 else15 {16 if(k>=d)17 {18 for(int i=0; i 2 #define max... 阅读全文
posted @ 2013-10-15 14:55 Yours1103 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 这个题是个数学题;2n个数,要求n个向上取整,n个向下取整,然后要求最后的数列之和与初始数列之和的差异最小;差异di=(1-ai)-(bi-0);容易看出ai与bi 的符号相同,故可以一次性将他们全部处理掉;最后用一个整数减去上面一步得到的数;得到的最小值就是我们所需要的;代码: 1 #include 2 #include 3 #include 4 using namespace std; 5 int n,cnt; 6 double x,ans; 7 int main() 8 { 9 scanf("%d",&n);10 double res=99999999;11 阅读全文
posted @ 2013-10-13 16:15 Yours1103 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 很简单的一个题;只需要将他们排一下序,然后判断一下就可以了!代码: 1 #include 2 #include 3 #define maxn 100005 4 using namespace std; 5 6 int n,x; 7 int a[maxn][2],cot; 8 struct node 9 {10 int v,id;11 bool operator<(node const &t)const12 {13 if(v==t.v)return id<t.id;14 return v<t.v;15 }16 } no[maxn]... 阅读全文
posted @ 2013-10-13 16:10 Yours1103 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 超级大水题;只要用到一个小学用过的结论就可;能被9整除的数它的各位数相加能被9整除:代码: 1 #include 2 #define maxn 1005 3 using namespace std; 4 int n,c0,c5,x; 5 int main() 6 { 7 cin>>n; 8 while(n--) 9 {10 cin>>x;11 if(x==0)c0++;12 else c5++;13 }14 if(c0==0){cout<<"-1";return 0;}15 c5=c5-c5%9;1... 阅读全文
posted @ 2013-10-13 16:08 Yours1103 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 思维题,感叹自己的智商不够啊。思路大概是这样的:1.排在队伍前面的女生是不用换位置的;2.女生在队伍中的顺序是不会变的;3.最后一个女生稳定了则程序结束;4.每个女生都有个初始位置和最终位置。如果一个女生的初始位置减去最终位置>现在的最大值,则最大值更新;否则最大值+1;代码: 1 #include 2 using namespace std; 3 char s; 4 int main() 5 { 6 int r=0,f=1,l=0; 7 while(getchar()=='F'); 8 while((s=getchar())=='F'||s==' 阅读全文
posted @ 2013-10-12 20:09 Yours1103 阅读(246) 评论(0) 推荐(0) 编辑
摘要: 感觉像是一个数位dp,高位的1如果不选的话,前面低位的数都可以选;不然只能选择为1的数;代码: 1 #include 2 #include 3 #define maxn 100005 4 using namespace std; 5 char s[maxn]; 6 int sum[maxn],num[maxn],n,ans,all; 7 8 int main() 9 {10 cin>>n;11 for(int i=1;i>num[i],sum[i]+=sum[i-1]+num[i];13 cin>>s;14 for(int i=n-1;i>=0;i--)15 阅读全文
posted @ 2013-10-12 19:29 Yours1103 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 如果某个数出现的次数大于或等于2次,那么平均分配到两个容器里面;这里利用一个k来使得当出现次数为奇数时候分配得更加均匀;剩下的就平均分配到两个容器里;代码: 1 #include 2 using namespace std; 3 4 int a[220],b[220],f[110],s,k,n; 5 int main() 6 { 7 cin >> n; 8 for(int i=0;i> a[i];11 f[a[i]]++;12 }13 for(int i=0;i=2)15 {16 s+=f[i]-2;17... 阅读全文
posted @ 2013-10-12 18:59 Yours1103 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 题意:要求找到最少次数的交换次数使得两组数都是偶数;很明显答案要么是0,要么是1,或者不管怎么交换都不行(-1);所以: 1 #include 2 #define maxn 105 3 using namespace std; 4 5 int n,x,y; 6 7 int main() 8 { 9 scanf("%d",&n);10 int a=0,b=0,c=0;11 while(n--)12 {13 scanf("%d%d",&x,&y);14 a+=x,b+=y;15 c+=(y%2)!=(x%2);16... 阅读全文
posted @ 2013-10-12 18:45 Yours1103 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 一道DP题;一共有三种砖,1*2,2*1,2*2,然后要你铺满整个n*2的地板,求不重复的铺法数;方法:首先计算了不考虑对称的情况,然后计算只考虑对称的情况;所以结果就是(不考虑对称数+只考虑对称数)/2;递推关系:dp[i] 表示左右各伸展 i 的对称情况。dp[i+1] += dp[i]//两边补上 1 x 2dp[i+2] += dp[i]*2//两边补上2x1 跟 2x2 兩种。然后只考虑对称的情况下有两种情况:n==奇数:中间有个1*2;n==偶数;中间有两个2*1;或者两个2*1或者一个2*2;代码: 1 #include 2 #include 3 using namespace 阅读全文
posted @ 2013-10-10 17:11 Yours1103 阅读(128) 评论(0) 推荐(0) 编辑
上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 26 下一页