群賽54

來源:互聯網
上載者:User

E - Relax! It's just a game a,b至少為1.才是==

http://livearchive.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2366

/*Problem ID:meaning:Analyzing:*/#include <iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<vector>using namespace std;typedef struct even{int y1,y2,x;}even;#define FOR(i,s,t) for(int i=(s); i<(t); i++)#define LL long long#define BUG puts("here!!!")#define STOP system("pause")#define file_r(x) freopen(x, "r", stdin)#define file_w(x) freopen(x, "w", stdout)#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define maxn 100005LL gcd(LL a,LL b) {return a?gcd(b%a,a):b;}int main(){    int a,b;    while(scanf("%d%d",&a,&b)){        if(a==-1&&b==-1) break;        int sum1=a+b;        int sum2=-1;        if(a==1||b==1) sum2=a+b;        if(sum1==sum2) printf("%d+%d=%d\n",a,b,sum1);        else printf("%d+%d!=%d\n",a,b,sum1);    }    return 0;}

H題Musical Chairs:約瑟夫環問題貼了個模版就過了..T_T

http://livearchive.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2369

/*Problem ID:meaning:Analyzing:*/#include <iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<vector>using namespace std;typedef struct even{int y1,y2,x;}even;#define FOR(i,s,t) for(int i=(s); i<(t); i++)#define LL long long#define BUG puts("here!!!")#define STOP system("pause")#define file_r(x) freopen(x, "r", stdin)#define file_w(x) freopen(x, "w", stdout)#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define maxn 16666LL gcd(LL a,LL b) {return a?gcd(b%a,a):b;}// Joseph's Problem// input: n,m-- the number of persons, the inteval between persons// output:-- return the reference of last personint josephus(int n, int m){    int l=0,c;    for(c=1;c<=n;c++)        l=(l+m-1)%c+1;    return l;}int main(){    int N,D,W;    while(~scanf("%d%d",&N,&D)&&(N||D)){        printf("%d %d %d\n",N,D,josephus(N,D));    }    return 0;}

k題: Boiled Eggs 貪心.開始沒範例結果WA了幾次。。55

http://lightoj.com/volume_showproblem.php?problem=1227

/*Problem ID:meaning:Analyzing:*/#include <iostream>#include<algorithm>#include<cstdio>#include<cstdlib>#include<cstring>#include<vector>using namespace std;typedef struct even{int y1,y2,x;}even;#define FOR(i,s,t) for(int i=(s); i<(t); i++)#define LL long long#define BUG puts("here!!!")#define STOP system("pause")#define file_r(x) freopen(x, "r", stdin)#define file_w(x) freopen(x, "w", stdout)#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define maxn 16666LL gcd(LL a,LL b) {return a?gcd(b%a,a):b;}int egg[35];int main(){    int i,n,p,q,T,sum,Cas=1;    scanf("%d",&T);    while(T--)    {        scanf("%d%d%d",&n,&p,&q);        for(i=0;i<n;i++)            scanf("%d",&egg[i]);        sum=0;        i=0;        sort(egg,egg+n);        while(1)        {            if(sum+egg[i]>q||i+1>p||i+1>n) break;            sum+=egg[i];            i++;        }        printf("Case %d: %d\n",Cas++,i);    }    return 0;}

C題:*匹配偶數個字元,#匹配奇數個字元.==不會了...待更

F題...

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.