24h購物| | PChome| 登入
2012-08-30 17:34:40| 人氣2,800| 回應0 | 上一篇 | 下一篇

[ITSA] 16th 總解答

推薦 0 收藏 0 轉貼0 訂閱站台

這次題目比較麻煩是輸入問題, 剩下的其實都還好, 解答就按照題目順序



#include <stdio.h>
#include <stdlib.h>

int main() {
    char s[1000], ch;
    int n, i;
    while(gets(s)) {
        scanf("%d", &n);
        while(ch = getchar()) {
            if(ch == '\n')
                break;
        }
        for(i = 0; s[i]; i++) {
            if(s[i] >= 'a' && s[i] <= 'z')
                printf("%c", (s[i]-'a'+n)%26+'a');
            else if(s[i] >= 'A' && s[i] <= 'Z')
                printf("%c", (s[i]-'A'+n)%26+'A');
            else if(s[i] >= '0' && s[i] <= '9')
                printf("%c", (s[i]-'0'+n)%10+'0');
            else
                printf("%c", s[i]);
        }
        puts("");
    }
    return 0;
}



#include <stdio.h>

int main() {
    int t, i, j;
    int n, m;
    char ch[1000][500][2];
    scanf("%d", &t);
    while(t--) {
        scanf("%d %d", &n, &m);
        for(i = 0; i < n; i++) {
            for(j = 0; j < m; j++)
                scanf("%s", ch[i][j]);
        }
        int p[1000] = {};
        for(i = 0; i < m; i++) {
            int Y = 0, N = 0;
            for(j = 0; j < n; j++)
                if(p[j] == 0) {
                    if(ch[j][i][0] == 'Y')
                        Y++;
                    else
                        N++;
                }
            if(N == 0)  N = 0xfffff;
            if(Y == 0)  Y = 0xfffff;
            if(Y > N) {
                for(j = 0; j < n; j++) {
                    if(p[j] == 0 && ch[j][i][0] == 'Y')
                        p[j] = 1;
                }
            } else if(Y < N) {
                for(j = 0; j < n; j++) {
                    if(p[j] == 0 && ch[j][i][0] == 'N')
                        p[j] = 1;
                }
            }
        }
        int at = -1, ans[1000] = {};
        for(i = 0; i < n; i++)
            if(p[i] == 0)
                ans[++at] = i;
        if(at >= 0) {
            printf("%d", ans[0]+1);
            for(i = 1; i <= at; i++)
                printf(" %d", ans[i]+1);
            puts("");
        } else {
            puts("");
        }
    }
    return 0;
}


#include <stdio.h>

int main() {
    int n, dd, a, b, x, y;
    while(scanf("%d", &n) == 1) {
        scanf("%d ", &dd);
        scanf("(%d,%d)", &x, &y);
        getchar();
        int flag = 0;
        while(n--) {
            scanf("(%d,%d)", &a, &b);
            getchar();
            if((x-a)*(x-a) + (y-b)*(y-b) <= dd*dd)
                printf("(%d,%d)\n", a, b), flag = 1;
        }
        if(!flag)
            puts("No Answer");
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main() {
    long long p[50][50] = {};
    int i, j;
    p[0][0] = 1;
    for(i = 1; i < 50; i++) {
        p[i][0] = 1;
        for(j = 1; j <= i; j++)
            p[i][j] = p[i-1][j] + p[i-1][j-1];
    }
    int n;
    while(scanf("%d", &n) == 1) {
        printf("%lld\n", p[n][6]);
        printf("%lld\n", p[n][6]*50);
        printf("%.2llf%%\n", (double)p[n][6]*100/p[49][6]);
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
int mm[13] = {0,0,31,59,90,120,151,181,212,243,273,304,334};
int cntDay(int y, int m, int d) {
    int lp, islp = 0;
    if(y%4 == 0 && y%100 != 0 || y%400 == 0)
        islp = 1;
    y--;
    lp = y/4 - y/100 + y/400;
    return y*365 + lp + mm[m] + d + (m > 2 ? islp : 0);
}
int main() {
    int t, base = cntDay(1981,7,1);
    int y, m, d;
    scanf("%d", &t);
    while(t--) {
        scanf("%d %d %d", &y, &m, &d);
        int tmp = cntDay(y, m, d);
        printf("%d\n", (abs(base - tmp)+3)%7+1);
    }
    return 0;
}


台長: Morris
人氣(2,800) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: 資訊競賽 |
此分類下一篇:[PTC] 201208D Instant Noodles [馬可夫鏈]
此分類上一篇:[ZJ][scc強連通元件][Tarjan算法] b201. F. 國家

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文