結果
| 問題 |
No.462 6日知らずのコンピュータ
|
| コンテスト | |
| ユーザー |
くれちー
|
| 提出日時 | 2016-12-13 01:24:52 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,167 bytes |
| コンパイル時間 | 274 ms |
| コンパイル使用メモリ | 25,216 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-29 23:58:24 |
| 合計ジャッジ時間 | 2,042 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 WA * 47 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:17:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
17 | scanf("%d %d", &n, &k);
| ^~~~~~~~~~~~~~~~~~~~~~
main.c:26:25: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
26 | scanf("%d", &a);
| ^~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <math.h>
#define rep(i, n) for (i = 0; i < n; i++)
#define MOD 1000000007
int getbit(int x, int n) {
return !!(x & (int)pow(2, n - 1));
}
int f(int x) {
if (x > 1) return (x * f(x - 1)) % MOD;
else return 1;
}
int main() {
int n, k;
scanf("%d %d", &n, &k);
int a, abit[61][60], cntb, cnt01, cnt10, flg = 0;
int maxb = -1, minb = n + 1;
int ans, i, j;
if (k == 0) ans = f(n);
else {
rep(i, k) {
scanf("%d", &a);
cntb = cnt01 = cnt10 = 0;
rep(j, n) {
abit[i][j] = getbit(a, j + 1);
if (abit[i][j]) cntb++;
}
if (cntb > maxb) maxb = cntb;
if (cntb < minb) minb = cntb;
if (i > 0) {
rep(j, n) {
int t1 = abit[i][j], t2 = abit[i - 1][j];
if (!t1 && t2) cnt01++;
else if (t1 && !t2) cnt10++;
}
if (cnt01 && cnt10) {
ans = 0;
goto ans;
}
else if (flg && cnt01 && flg != 1) {
ans = 0;
goto ans;
}
else if (flg && cnt10 && flg != 2) {
ans = 0;
goto ans;
}
if (!flg && cnt01) flg = 1;
else if (!flg && cnt10) flg = 2;
}
}
ans = f(minb) * f(maxb - minb) * f(n - maxb);
}
ans: printf("%d\n", ans);
return 0;
}
くれちー