結果
| 問題 | 
                            No.1797 永遠のグリッド
                             | 
                    
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-08-14 16:09:36 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 246 bytes | 
| コンパイル時間 | 1,908 ms | 
| コンパイル使用メモリ | 193,352 KB | 
| 最終ジャッジ日時 | 2025-01-30 22:31:16 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 27 | 
コンパイルメッセージ
main.cpp:2:43: 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,c;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++);c=H*W/h/w*__gcd(h,w);t+=pow(3,c);u+=pow(2,c);}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,c;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++);c=H*W/h/w*__gcd(h,w);t+=pow(3,c);u+=pow(2,c);}t/=H*W;u/=H*W;cout<<(K-1?K-2?t-3*u+3:u-2:1)<<"\n";}