码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces #107 DIV2 ABCD

时间:2014-10-27 00:25:19      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   os   ar   for   sp   

A

bubuko.com,布布扣
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define PI 3.1415926535897932626
using namespace std;
int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);}
int n,k,l, c,d,p,nl,np;
int main()
{
        while (cin >> n >> k >> l >> c >> d >> p >> nl >> np)
        {
                int a1 = k * l / nl;
                int a2 = p / np;
                int a3 = c * d;
                cout << min(a1,min(a2,a3)) / n << endl;
        }
        return 0;
}
View Code

B

bubuko.com,布布扣
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define PI 3.1415926535897932626
using namespace std;
int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);}
struct node
{
        int girl;
        int pizza;
        int taxi;
        int s;
}src[110];
char name[110][30];
int main()
{
       // freopen("sample.txt","r",stdin);
        int N;
        while (scanf("%d",&N) != EOF)
        {
                for (int i = 0 ; i < N ; i++)
                {
                        scanf("%d%s",&src[i].s,name[i]);
                        src[i].girl = src[i].pizza = src[i].taxi = 0;
                        for (int j = 0 ; j < src[i].s; j++)
                        {
                                char tmp[30];
                                scanf("%s",tmp);
                                bool flag =true;
                                int cnt[30];memset(cnt,0,sizeof(cnt));
                                cnt[tmp[0] - 0] ++; cnt[tmp[1] -0] ++;cnt[tmp[3] -0]++;
                                cnt[tmp[4] - 0] ++; cnt[tmp[6] - 0] ++;cnt[tmp[7]  - 0]++;
                                for (int j = 0 ; j < 11;j++) if (cnt[j]  >= 6) flag = false;
                               // printf("%d %d %d\n",a,b,c);
                                if (!flag) src[i].taxi++;
                                else if (tmp[0] - 0 > tmp[1] - 0 && tmp[1] -0 > tmp[3] - 0 && tmp[3] -0 > tmp[4] - 0 && tmp[4] - 0 > tmp[6] -0 &&
                                         tmp[6] - 0 > tmp[7] - 0) src[i].pizza++;
                                else src[i].girl++;
                        }
                }
                int anstaxi = -1,st[110],casst = 0;
                int anspizza = -1,sp[110],cassp = 0;
                int ansgirl = -1,sg[110],cassg = 0;;
                for (int i = 0 ; i < N; i++)
                {
                        if (anstaxi < src[i].taxi) {anstaxi = src[i].taxi; casst = 0; st[casst++] = i;}
                        else if (anstaxi == src[i].taxi) {st[casst++]= i;}
                        if (anspizza  < src[i].pizza)  {anspizza = src[i].pizza ; cassp = 0; sp[cassp++] = i;}
                        else if (anspizza == src[i].pizza) {sp[cassp++]= i;}
                        if (ansgirl < src[i].girl) {ansgirl = src[i].girl; cassg = 0; sg[cassg++] = i;}
                        else if (ansgirl == src[i].girl) {sg[cassg++]= i;}
                }
                printf("If you want to call a taxi, you should call: ");
                for (int i = 0 ; i < casst ; i++)
                {
                        if (i == casst - 1) printf("%s.\n",name[st[i]]);
                        else printf("%s, ",name[st[i]]);
                }
                printf("If you want to order a pizza, you should call: ");
                for (int i = 0 ; i < cassp; i++)
                {
                        if (i == cassp  - 1) printf("%s.\n",name[sp[i]]);
                        else printf("%s, ",name[sp[i]]);
                }
                printf("If you want to go to a cafe with a wonderful girl, you should call: ");
                for (int i = 0 ; i < cassg; i++)
                {
                        if (i == cassg - 1) printf("%s.\n",name[sg[i]]);
                        else printf("%s, ",name[sg[i]]);
                }
        }
        return 0;
}
View Code

C

bubuko.com,布布扣
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define PI 3.1415926535897932626
using namespace std;
int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);}
vector <LL>G;
int main()
{
        LL N;
        while (cin >> N)
        {
                G.clear();
                for (LL  i = 2 ; i * i <= N; i++)
                        while (N % i == 0)
                {
                        G.push_back(i);
                        N /= i;
                }
                if (N > 1) G.push_back(N);
                if (G.size() < 2) cout << 1 << endl << 0 <<endl;
                else if (G.size() == 2) cout << 2 <<endl;
                else cout <<1 << endl << G[0] * G[1] <<endl;
        }
        return 0;
}
View Code

D

bubuko.com,布布扣
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define PI 3.1415926535897932626
using namespace std;
int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);}
#define MOD 1000000007
LL n,m,k;
LL mypow(LL a,LL b)
{
        LL ans = 1;
        for (LL i = 1 ; i <= b; i++)
        ans = (ans * a) % MOD;
        return ans;
}
int main()
{
        while (cin >> n >> m >> k)
        {
                LL ans;
                if(k > n || k == 1) ans = mypow(m,n);
                else if (k == n) ans = mypow(m,(k + 1)/2);
                else
                {
                        if (k % 2) ans = m * m;
                        else ans = m;
                }
                cout << ans <<endl;
        }
        return 0;
}
View Code

 

Codeforces #107 DIV2 ABCD

标签:style   blog   http   color   io   os   ar   for   sp   

原文地址:http://www.cnblogs.com/Commence/p/4053035.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!