發表文章

目前顯示的是有「codeforces」標籤的文章

[CF]A. Gabriel and Caterpillar

題目: http://codeforces.com/problemset/problem/652/A --------------------------------------------------------------------------------- #include <bits/stdc++.h> using namespace std; const int n = 4e5 + 5; int main() {   int h1, h2;   int a, b;   scanf("%d%d",&h1,&h2);   scanf("%d%d",&a,&b);   h1 += 8 * a;   if(h1 >= h2){     printf("0\n");     return 0;   }   h1 -= 12 * b;   if(a <= b){     printf("-1\n");     return 0;   }   int day = 1;   for(int i=0;i<n;i++){     h1 += 12 * a;     if(h1 >= h2){       printf("%d\n",day);       return 0;     }     h1 -= 12 * b;     day++;   }   printf("-1\n");   return 0; }

[CF]600B - Queries about less or equal elements

題目: http://codeforces.com/problemset/problem/600/B ---------------------------------------------------------------------------------------------------- #include<bits/stdc++.h> using namespace std; #define MAXN 200010 int main() {     int n,m;     while(scanf("%d%d",&n,&m)!=EOF)     {         int a[MAXN] = {0},i=0,c = 0,*sum,b[MAXN] = {0};         for(i=0;i<n;i++)             scanf("%d",&a[i]);         sort(a,a+n);         for(int i=0;i<m;i++)             scanf("%d",&b[i]);         for(int i=0;i<m;i++)         {             sum = upper_bound(a,a+n,b[i]);             printf("%d%c",sum-a,i==m-1?'\n':' ');         }     }     retur...

[CF]581B - Luxurious Houses

題目: http://codeforces.com/problemset/problem/581/B ----------------------------------------------------------------------------------- #include<bits/stdc++.h> #define N 100050 using namespace std; int main(void) {     int n;     while(scanf("%d",&n)!=EOF)     {         int a[N]={0},mxn[N]={0};         for(int i=0;i<n;i++)             scanf("%d",&a[i]);         for(int i=n-1;i>=1;i--)             mxn[i] = max(mxn[i+1],a[i]);         for(int i=0;i<n;i++)             printf("%d ",max(0,mxn[i+1]-a[i]+1));         printf("\n");     }         return 0; }

[CF]581A - Vasya the Hipster

題目: http://codeforces.com/problemset/problem/581/A ------------------------------------------------------------------------- #include<bits/stdc++.h> using namespace std; int main(void) {     int a,b;     while(scanf("%d%d",&a,&b)!=EOF)     {         int mxn = 0, mn = 0;         if(a == b)             printf("%d %d\n",a,0);         else         {             mxn = max(a,b);             mn = min(a,b);             mxn -= mn;             printf("%d %d\n",mn,mxn/2);         }     }     return 0;  }

[CF]580A - Kefa and First Steps

題目: http://codeforces.com/problemset/problem/580/A ------------------------------------------------------------------------------------------- #include<iostream> #include<cstdio> using namespace std; int main(void) {     int n;     while(scanf("%d",&n)!=EOF)     {     int x = 0,y = 0,mx = 1,cnt = 1;     for(int i=0;i<n;i++)     {         scanf("%d",&x);         if(x>=y && i!=0)         {             cnt++;         }           else             cnt = 1;         if(cnt > mx)             mx = cnt;         y = x;     }       cout << mx << endl; } return 0; }

[CF]510A - Fox And Snake

題目: http://codeforces.com/problemset/problem/510/A ------------------------------------------------------------------------------------------------- #include<cstdio> #include<cstdlib> #include<cstring> #define N 100 int main(void) {     long int n,m;     while(scanf("%d%d",&n,&m)!=EOF)     {         int x[N][N];         memset(x,0,sizeof(x));         for(int i=1;i<=n;i++)         {             for(int j=1;j<=m;j++)             {                               if(i%4==0 && j!=1)                 {                     printf(".");                 }   ...

[CF]495A - Digital Counter

題目: http://codeforces.com/problemset/problem/495/A ---------------------------------------------------------------------------------------------------- #include <cstdio> int main() {       int ara[]={2,7,2,3,3,4,2,5,1,2};       int a;       while(scanf("%d",&a)!=EOF)         printf("%d\n",ara[a%10]*ara[(a/10)%10]);     return 0; }