提出 #45322549


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std; 
const int P = 1000000007, N = 402; 
inline void add(int &x, int t) { x += t; x -= x >= P ? P : 0; }

int n, c; 
int a[405], b[405]; 
int f[405][405]; // 前 i 个人分 j 个糖果
int pw[405][405]; 

int main(void) {
    scanf("%d%d", &n, &c); 
    for (int i = 1; i <= 400; ++i) {
        pw[i][0] = 1; 
        for (int j = 1; j <= 400; ++j) pw[i][j] = 1ll * pw[i][j - 1] * i % P; 
    }
    for (int i = 1; i <= 400; ++i) for (int j = 0; j <= 400; ++j) add(pw[i][j], pw[i - 1][j]); 
    for (int i = 1; i <= n; ++i) scanf("%d", a + i); 
    for (int i = 1; i <= n; ++i) scanf("%d", b + i); 
    f[0][0] = 1; 
    for (int i = 1; i <= n; ++i)
        for (int j = 0; j <= c; ++j)
            for (int k = 0; k <= j; ++k)
                add(f[i][j], 1ll * f[i - 1][j - k] * (pw[b[i]][k] - pw[a[i] - 1][k] + P) % P); 
    printf("%d\n", f[n][c]); 
    return 0; 
}

提出情報

提出日時
問題 E - キャンディーとN人の子供
ユーザ james1BadCreeper
言語 C++ 20 (gcc 12.2)
得点 800
コード長 939 Byte
結果 AC
実行時間 73 ms
メモリ 5148 KiB

コンパイルエラー

Main.cpp: In function ‘int main()’:
Main.cpp:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |     scanf("%d%d", &n, &c);
      |     ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:18:39: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |     for (int i = 1; i <= n; ++i) scanf("%d", a + i);
      |                                  ~~~~~^~~~~~~~~~~~~
Main.cpp:19:39: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |     for (int i = 1; i <= n; ++i) scanf("%d", b + i);
      |                                  ~~~~~^~~~~~~~~~~~~

ジャッジ結果

セット名 Sample Subtask All
得点 / 配点 0 / 0 400 / 400 400 / 400
結果
AC × 5
AC × 12
AC × 30
セット名 テストケース
Sample 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt
Subtask 0_001, 0_003, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 2_017.txt, 2_018.txt, 2_019.txt, 2_020.txt, 2_021.txt, 2_022.txt, 2_023.txt, 2_024.txt, 2_025.txt, 2_026.txt, 2_027.txt, 2_028.txt, 2_029.txt
ケース名 結果 実行時間 メモリ
0_000.txt AC 2 ms 4520 KiB
0_001.txt AC 2 ms 4316 KiB
0_002.txt AC 2 ms 4276 KiB
0_003.txt AC 2 ms 4328 KiB
0_004.txt AC 2 ms 4320 KiB
1_005.txt AC 2 ms 4408 KiB
1_006.txt AC 2 ms 4328 KiB
1_007.txt AC 2 ms 4320 KiB
1_008.txt AC 2 ms 4276 KiB
1_009.txt AC 2 ms 4452 KiB
1_010.txt AC 2 ms 4228 KiB
1_011.txt AC 2 ms 5028 KiB
1_012.txt AC 2 ms 4956 KiB
1_013.txt AC 2 ms 5148 KiB
1_014.txt AC 73 ms 5092 KiB
1_015.txt AC 73 ms 4948 KiB
1_016.txt AC 73 ms 4920 KiB
2_017.txt AC 2 ms 4408 KiB
2_018.txt AC 2 ms 4296 KiB
2_019.txt AC 2 ms 4332 KiB
2_020.txt AC 2 ms 4332 KiB
2_021.txt AC 2 ms 4912 KiB
2_022.txt AC 2 ms 4920 KiB
2_023.txt AC 73 ms 4860 KiB
2_024.txt AC 73 ms 4968 KiB
2_025.txt AC 13 ms 4852 KiB
2_026.txt AC 2 ms 4900 KiB
2_027.txt AC 58 ms 4972 KiB
2_028.txt AC 3 ms 4572 KiB
2_029.txt AC 2 ms 4340 KiB