上一页 1 2 3 4 5 6 ··· 8 下一页
摘要: #include<stdio.h>#include<string.h>#define max( a , b ) a > b ? a : b#define INF 10000000int main (){ int t , m ; int T[1050] , P[1005] ; int dp[10005] ; while( scanf("%d%d" , &t , &m )==2 ) { for( int i = 0 ; i < m ; i++ ) { scanf("%d%d" , &T[i] , & 阅读全文
posted @ 2011-09-02 21:30 bcy 阅读(331) 评论(0) 推荐(0) 编辑
摘要: #include"iostream"#include"cstdio"#include"cstring"using namespace std;int N,num[200005];int main(){ while(scanf("%d",&N),N) { int res=0; for(int i=0;i<N;++i) scanf("%d",&num[i]),res^=num[i]; if(res==0) puts("No"); else { puts(&q 阅读全文
posted @ 2011-08-28 11:01 bcy 阅读(196) 评论(0) 推荐(0) 编辑
摘要: #include"iostream"#include"cstdio"using namespace std;int num[1000005],n;int main(){ while(scanf("%d",&n),n) { int s=0,temp,res=0; for(int i=0;i<n;++i) scanf("%d",&num[i]),res^=num[i]; if(res==0) puts("0"); else { for(int i=0;i<n;++i) { 阅读全文
posted @ 2011-08-28 10:07 bcy 阅读(179) 评论(0) 推荐(0) 编辑
摘要: #include"stdio.h"int main(){ int n,m,t; scanf("%d",&t); while(t--&&scanf("%d%d",&n,&m)) puts(n%(m+1)?"first":"second"); return 0; } 这是一个巴什博弈的题目,要想让第二个人赢,只有当(m+1)是n的因子时才成立,所以直接puts就可以了。 阅读全文
posted @ 2011-08-19 21:54 bcy 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 题意:求两个大数的和;(注意输出格式)#include"stdio.h"#include"string.h"int shu(char a){ return (a-'0');}int main(){ char a[1000],b[1000]; int num[1001]; int n,i,j=1,al,bl,k,t; scanf("%d",&n); while(n--) { getchar(); if(j!=1) printf("\n"); scanf("%s",& 阅读全文
posted @ 2011-08-15 10:55 bcy 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 题意:求前某项的和最大#include"stdio.h"#define min -99999999int sta,end;int main(){ int n,i,j,t,sum,maxsum,in,b; scanf("%d",&n); for(i=0;i<n;i++) { sum=0;maxsum=min;sta=0; scanf("%d",&t); for(b=j=0;j<t;j++) { scanf("%d",&in); sum+=in; if(sum>maxsum) 阅读全文
posted @ 2011-08-14 21:06 bcy 阅读(148) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>main(){ int n; for(n=2000;n<=2500;n++) if(n%4==0&&n%100!=0||n%400==0) printf("%d是闰年\n",n); else printf("%d不是闰年\n",n);}#include <stdio.h>main(){ int m,n; for(m=1,n=2;n<=5;n++) { m*=n; } printf("%d\n",m); 阅读全文
posted @ 2011-08-11 17:24 bcy 阅读(176) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<math.h>#define L 10void conversion(int N,int r){ int s[L],top; int x; top=-1; while(N) { s[++top]=N%r; N=N/r; } while(top!=-1) { x=s[top--]; printf("%d\n",x); } printf("\n");}main(){ int N,r; scanf("%d%d",&N,&r);conversion(N 阅读全文
posted @ 2011-08-11 17:19 bcy 阅读(154) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>int N, M, set[1010];int find ( int x ) { return x==set[x]?x:set[x]= find ( set[x] ); }void Union ( int x, int y ) { int a = find (x), b = find(y); if ( a != b ) { set[a] = b; } }int main () { int a, b, x, y, sum; while ( scanf ( 阅读全文
posted @ 2011-08-11 17:17 bcy 阅读(130) 评论(0) 推荐(0) 编辑
摘要: void Swap(int& x,int& y){int temp = x;x = y;y = temp;}void quicksort(int array[], int left, int right) {//快速排序的函数(以中间的数为标准) int i, j, s; if(left < right) { s = array[(left+right)/2]; i = left - 1; j = right + 1; while(1) { while(array[++i] < s) ; while(array[--j] > s) ; if(i >= j 阅读全文
posted @ 2011-08-11 17:16 bcy 阅读(198) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 8 下一页