結果
問題 |
No.1797 永遠のグリッド
|
ユーザー |
|
提出日時 | 2022-08-14 16:07:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 257 bytes |
コンパイル時間 | 1,979 ms |
コンパイル使用メモリ | 192,884 KB |
最終ジャッジ日時 | 2025-01-30 22:30:57 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
コンパイルメッセージ
main.cpp:2:41: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type] 2 | using namespace std;int H,W,K,t,u,i,h,w;main(){cin>>H>>W>>K;for(;i<H;i++)for(int j=0;j<W;){h=H/__gcd(H,i);w=W/__gcd(W,j++);t+=pow(3,H*W/h/w*__gcd(h,w));u+=pow(2,H*W/h/w*__gcd(h,w));}t/=H*W;u/=H*W;cout<<(K-1?K-2?t-3*u+3:u-2:1)<<"\n";} | ^~~~
ソースコード
#include<bits/stdc++.h> using namespace std;int H,W,K,t,u,i,h,w;main(){cin>>H>>W>>K;for(;i<H;i++)for(int j=0;j<W;){h=H/__gcd(H,i);w=W/__gcd(W,j++);t+=pow(3,H*W/h/w*__gcd(h,w));u+=pow(2,H*W/h/w*__gcd(h,w));}t/=H*W;u/=H*W;cout<<(K-1?K-2?t-3*u+3:u-2:1)<<"\n";}