結果

問題 No.474 色塗り2
コンテスト
ユーザー vjudge1
提出日時 2025-06-28 16:44:31
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.90.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,262 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,219 ms
コンパイル使用メモリ 205,388 KB
実行使用メモリ 9,416 KB
最終ジャッジ日時 2026-07-12 22:45:52
合計ジャッジ時間 2,377 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 1 WA * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void FileIO()’:
main.cpp:5:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |     freopen("color.in","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:6:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |     freopen("color.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;

void FileIO(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
}

namespace sunburstfan{
    int mod2(int c,int k){
        if(k==0) return 1; 
        if(c==0) return 0;
        return (c&1);   
    }
    
    vector<int> get(int n){
        vector<int> divs;
        for(int i=1;i*i<=n;i++){
            if(n%i==0){
                divs.push_back(i);
                if(i!=n/i){
                    divs.push_back(n/i);
                }
            }
        }
        return divs;
    }

    void solve(){
        int a,b,c;
        cin>>a>>b>>c;
        
        vector<int> div_a=get(a);
        vector<int> div_b=get(b);
        
        int res=0;
        for(auto i:div_a){
            int g=a/i;
            for(auto j:div_b){
                int h=b/j;
                int w=1;
                w=(w*(c&1))&1;   
                w=(w*mod2(c,g))&1; 
                w=(w*mod2(c,g*h))&1;   
                res=(res+w)&1;
            }
        }
        cout<<res<<"\n";
    }
}

using namespace sunburstfan;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    //FileIO();

    int T;
    cin>>T;
    while(T--){
        solve();
    }
    
    return 0;
}
0