程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> Codeforces Round #235 (Div. 2)

Codeforces Round #235 (Div. 2)

編輯:C++入門知識

Problems \ # Name A Vanya and Cards standard input/output 1 s, 256 MB Submit Add to favourites \ x2537 B Sereja and Contests standard input/output 1 s, 256 MB Submit Add to favourites \ x1911 C Team standard input/output 1 s, 256 MB Submit Add to favourites \ x1573 D Roman and Numbers standard input/output 4 s, 512 MB Submit Add to favourites \ x464 E Olympic Games standard input/output 2 s, 256 MB Submit Add to favourites \ x63

A題:水題,先計算總和,盡量往大了取,所以答案就是sum / x + (sum % x != 0)。

B題:最多的情況是全是DIV2,最少的情況是盡量有DIV1和DIV2和開,用一個vis數組記錄已經開過的場,for循環找過去即可。<喎?http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+Q8zio7puuPYwo6xtuPYxo6wx1rvE3NPQMbj2u/IyuPbX6bPJ0rvG8KOsyLu689PQbrj2MKOs1+7J2b7N0qpuIC0gMbj2MaOs1+624L/J0tTT0ChuICYjNDM7IDEpICogMiCjqDG/ydLUtuC3xcG9sd+jqcv50tTPyMXQts9uIC0gMSA8PSBtIDw9IChuICYjNDM7IDEpICogMqOsyLu689TayKXEo8Tit8W+zb/J0tTBy6GjPC9wPgo8cD5EzOKjurzH0uS7r8vRy/ejrGRwW3NdW21dtPqx7byvus/OqnOjrMihxKPOqm1vtcTXtMyso6zIu7rzyKXSu7j20MK1xMr919a3xdTauvPD5qOsbbHks8kobW8gKiAxMCAmIzQzOyBudW0pICUgbSy9+NDQvMfS5Luvy9HL97y0v8mhozwvcD4KPHA+tPrC66O6PC9wPgo8cD5BzOKjujwvcD4KPHA+PHByZSBjbGFzcz0="brush:java;">#include #include #include int n, x, sum; int main() { int num; scanf("%d%d", &n, &x); while (n--) { scanf("%d", &num); sum += num; } printf("%d\n", abs(sum) / x + (abs(sum) % x != 0)); return 0; }B題:

#include 
#include 

int x, n, vis[4005];

int main() {
    scanf("%d%d", &x, &n);
    int v, d1, d2;
    while (n--) {
        scanf("%d", &v);
        if (v == 1) {
            scanf("%d%d", &d1, &d2);
            vis[d1] = 1; vis[d2] = 1;
        }
        else {
            scanf("%d", &d2);
            vis[d2] = 1;
        }
    }
    vis[0] = 1;
    int ans1 = 0, ans2 = 0, i;
    for (i = 1; i < x; i++)
        if (!vis[i]) ans1++;
    for (i = 1; i < x; i++)
        if (!vis[i] && !vis[i - 1]) {
            ans2++;
            vis[i] = vis[i - 1] = 1;
        }
    for (i = 1; i < x; i++)
        if (!vis[i]) ans2++;
    printf("%d %d\n", ans2, ans1);
    return 0;
}

C題:

#include 
#include 

int n, m;

int main() {
    scanf("%d%d", &n, &m);
    if (m < n - 1 || m > (n + 1) * 2) {
        printf("-1\n");
        return 0;
    }
    if (m - (n - 1) * 2 == 1)
        printf("1");
    if (m - (n - 1) * 2 >= 2)
        printf("11");
    int mm;
    if (m > (n - 1) * 2) mm = (n - 1) * 2;
    else mm = m;
    int m2 = mm - (n - 1);
    int m1 = (n - 1) - m2;
    int nn = n;
    while (m2--) {
        if (nn--) printf("0");
        printf("11");
    }
    while (m1--) {
        if (nn--) printf("0");
        printf("1");
    }
    if (nn--)printf("0");
    if (m - (n - 1) * 2 == 3)
        printf("1");
    if (m - (n - 1) * 2 == 4)
        printf("11");
    printf("\n");
    return 0;
}

D題:

#include 
#include 

char str[20];
int num[20], m, n, vis[(1<<18)][105];
__int64 dp[(1<<18)][105];

__int64 dfs(int s, int mo) {
	__int64 &ans = dp[s][mo];
	if (vis[s][mo]) return ans;
	vis[s][mo] = 1;
	int v[10];
	memset(v, 0, sizeof(v));
	if (s == (1<



  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved