結果
問題 | No.87 Advent Calendar Problem |
ユーザー |
![]() |
提出日時 | 2014-12-07 00:26:55 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 813 bytes |
コンパイル時間 | 586 ms |
コンパイル使用メモリ | 71,768 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-11 15:55:17 |
合計ジャッジ時間 | 1,393 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:44:14: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=] 44 | printf("%d\n",ans-3); | ~^ ~~~~~ | | | | int long long int | %lld main.cpp:20:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | scanf("%lld",&n); | ~~~~~^~~~~~~~~~~
ソースコード
#include <cstdio>#include <cstdlib>#include <iostream>#include <string>#include <cmath>#include <algorithm>#include <vector>#include <queue>#include <stack>#include <map>using namespace std;int main(){long long n,daym[7]={0},day=0,ans;scanf("%lld",&n);for(int i=1;i<=400;i++){if((i%4==0 && i%100!=0) || i%400==0)day=(day+2)%7;elseday=(day+1)%7;daym[day]++;}ans=(n-2000)/400*daym[3];day=0;for(int i=1;i<=(n-2000)%400;i++){if((i%4==0 && i%100!=0) || i%400==0)day=(day+2)%7;elseday=(day+1)%7;if(day==3)ans++;}printf("%d\n",ans-3);return 0;}