SSブログ

Codeforces Beta Round #99 (Div. 2) [コンテスト]

自信喪失の中、初Codeforces.
部屋5位、全体で196位くらい.
結果:oxo--
Rating: - -> 1603

A. Petr and Book
やるだけ.
#include <stdio.h>

int main(void)
{
    int n;
    int read[7];
    int ans;
    int i;
    
    scanf("%d", &n);
    
    for (i = 0; i < 7; i++){
        scanf("%d", &read[i]);
    }
    
    ans = -1;
    while (n > 0){
        ans = (ans + 1) % 7;
        n -= read[ans];
    }
    
    printf("%d\n", ans + 1);
    
    return (0);
}


B.Wallpaper
問題文がよくわからない...
ceilとか使ってるけど見ても意味が分からない.本当に解釈がわからなかった...(×なコード)
#include <stdio.h>
#include <math.h>

#define INF (100000000)

typedef struct {
    int a, b, c;
} ROOM;

typedef struct {
    int w, h, m;
} ROLL;

int min(int a, int b)
{
    if (a > b){
        return (b);
    }
    
    return (a);
}

int main(void)
{
    ROOM room[500];
    ROLL roll[500];
    int m, n;
    int i, j;
    int min_, sum, num;
    int wall;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++){
        scanf("%d%d%d", &room[i].a, &room[i].b, &room[i].c);
    }
    
    scanf("%d", &m);
    
    for (i = 0; i < m; i++){
        scanf("%d%d%d", &roll[i].w, &roll[i].h, &roll[i].m);
    }
    
    sum = 0;
    for (i = 0; i < n; i++){
        min_ = INF;
        for (j = 0; j < m; j++){
            wall = 2 * (room[i].a + room[i].b);
            
            num = (roll[j].w / room[i].c) * roll[j].h;
            min_ = min(min_, roll[j].m * (int)(ceil((double)wall / (double)num)));
        }
        sum += min_;
    }
    
    printf("%d\n", sum);
    
    return (0);
}


3.Literature Lesson
制約が細かいのですが、書かれているとおりに実装すればOKです.
aaaaが神.
#include <stdio.h>
#include <string.h>

int main(void)
{
    int i, j;
    char type[5][5] = {"aabb", "abab", "abba", "aaaa", "NO"};
    int n, k;
    char str[4][10001];
    char substr[4][10001];
    int t;
    int ans;
    int len;
    
    scanf("%d%d", &n, &k);
    
    ans = 3;
    for (i = 0; i < n; i++){
        for (j = 0; j < 4; j++){
            scanf("%s", str[j]);
            len = strlen(str[j]);
            len--;
            t = 0;
            while (len != -1){
                if (str[j][len] == 'a' || str[j][len] == 'e' || str[j][len] == 'i' || str[j][len] == 'o' || str[j][len] == 'u'){
                    t++;
                }
                if (t == k){
                    break;
                }
                len--;
            }
            if (len == -1){
                ans = 4;
            }
            else {
                strcpy(substr[j], &str[j][len]);
            }
        }
        if (strcmp(substr[0], substr[1]) == 0 && strcmp(substr[0], substr[2]) == 0 && strcmp(substr[0], substr[3]) == 0 && ans == 3){
            ans = 3;
        }
        else if (strcmp(substr[0], substr[1]) == 0 && strcmp(substr[2], substr[3]) == 0 && (ans == 3 || ans == 0)){
            ans = 0;
        }
        else if (strcmp(substr[0], substr[2]) == 0 && strcmp(substr[1], substr[3]) == 0 && (ans == 3 || ans == 1)){
            ans = 1;
        }
        else if (strcmp(substr[0], substr[3]) == 0 && strcmp(substr[1], substr[2]) == 0 && (ans == 3 || ans == 2)){
            ans = 2;
        }
        
        else {
            ans = 4;
            
        }
    }
    
    printf("%s\n", type[ans]);
    
    return (0);
}

nice!(0)  コメント(0)  トラックバック(0) 

nice! 0

コメント 0

コメントを書く

お名前:
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。

トラックバック 0

1年を振り返って.AOJ 0525: Osenbei ブログトップ

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。