結果

問題 No.1632 Sorting Integers (GCD of M)
ユーザー chocorusk
提出日時 2021-07-30 20:47:11
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,060 bytes
コンパイル時間 3,160 ms
コンパイル使用メモリ 181,940 KB
最終ジャッジ日時 2025-01-23 10:31:26
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 47 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint1000000007;
int main()
{
	int n; cin>>n;
	int c[10];
	int k=0;
	for(int i=1; i<=9; i++){
		cin>>c[i];
		if(c[i]) k++;
	}
	if(k==1){
		for(int i=1; i<=9; i++){
			if(c[i]){
				mint ans=(mint(10).pow(n)-1)/9*i;
				cout<<ans.val()<<endl;
			}
		}
		return 0;
	}
	int g=0;
	for(int i=1; i<=9; i++) if(c[i]) g=gcd(g, i);
	ll s=0;
	for(int i=1; i<=9; i++){
		s+=i/g*c[i];
	}
	if(s%9==0) g*=9;
	else if(s%3==0) g*=3;
	cout<<g<<endl;
    return 0;
}
0