結果
問題 | No.612 Move on grid |
ユーザー |
![]() |
提出日時 | 2017-11-30 00:23:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,548 bytes |
コンパイル時間 | 309 ms |
コンパイル使用メモリ | 43,764 KB |
実行使用メモリ | 14,464 KB |
最終ジャッジ日時 | 2024-11-27 19:19:39 |
合計ジャッジ時間 | 54,413 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 TLE * 1 |
other | AC * 3 TLE * 14 |
ソースコード
#include <cstdio> #include <cstdlib> #include <algorithm> using namespace std; typedef long long int ll; const int MAX_T = 500; const int MOD = 1000000007; int T, a, b, c, d, e; int comb[MAX_T + 10][MAX_T + 10]; int main() { for(int i=0; i<=MAX_T; i++) comb[i][0] = 1; for(int i=1; i<=MAX_T; i++) { for(int j=1; j<=i; j++) comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % MOD; } scanf("%d%d%d%d%d%d", &T, &a, &b, &c, &d, &e); int ans = 0; for(int x=-T; x<=T; x++) { int P = T - abs(x); for(int y=-P; y<=P; y++) { int Q = P - abs(y); for(int z=-Q; z<=Q; z++) { int rest = Q - abs(z); if(rest % 2) continue; rest = rest / 2 * 2; int val = a*x + b*y + c*z; if(val < d || e < val) continue; for(int i=0; i<=rest; i+=2) { for(int j=0; j<=rest-i; j+=2) { int k = rest - i - j; int X = abs(x), Y = abs(y), Z = abs(z); int N = T; int array[] = {X+i/2, i/2, Y+j/2, j/2, Z+k/2, k/2}; long long int temp = 1; for(int s=0; s<6; s++) { (temp *= comb[N][array[s]]) %= MOD; N -= array[s]; } (ans += temp) %= MOD; } } } } } printf("%d\n", ans); return 0; }