結果

問題 No.991 N×Mマス計算(構築)
ユーザー chocoruskchocorusk
提出日時 2020-02-15 06:04:54
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,490 bytes
コンパイル時間 1,109 ms
コンパイル使用メモリ 110,684 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 03:06:35
合計ジャッジ時間 6,082 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 69 ms
5,376 KB
testcase_02 AC 69 ms
5,376 KB
testcase_03 AC 68 ms
5,376 KB
testcase_04 AC 68 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 65 ms
5,376 KB
testcase_07 AC 67 ms
5,376 KB
testcase_08 AC 68 ms
5,376 KB
testcase_09 AC 68 ms
5,376 KB
testcase_10 AC 66 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 68 ms
5,376 KB
testcase_15 AC 67 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 71 ms
5,376 KB
testcase_19 AC 68 ms
5,376 KB
testcase_20 AC 66 ms
5,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 69 ms
5,376 KB
testcase_25 WA -
testcase_26 AC 67 ms
5,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 72 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll gcd(ll a, ll b){
	if(b==0) return a;
	return gcd(b, a%b);
}
ll inv(ll a, ll m){
    ll b=m, x=1, y=0;
    while(b>0){
        ll t=a/b;
        swap(a-=t*b, b);
        swap(x-=t*y, y);
    }
    return (x%m+m)%m;
}
int main()
{
	ll x; cin>>x;
	if(x==0){
		cout<<"3 2 129"<<endl;
		cout<<"+ 12 34"<<endl;
		cout<<10<<endl;
		cout<<20<<endl;
		cout<<30<<endl;
		return 0;
	}
	int n=50000, m;
	if(x%n==0) n++;
	ll k=1e9;
	ll b[100010], a[100010];
	a[0]=k;
	for(int i=0; i<x/n; i++) b[i]=k;
	int r=x%n;
	m=x/n+r;
	int r1=r;
	while(1){
		ll g=gcd(r1, k);
		if(x%g==0) break;
		r1++;
	}
	for(int i=0; i<r; i++){
		if(i<r1-r) b[i]=2;
		else b[i]=1;
	}
	ll g=gcd(r1, k);
	ll y=inv(r1/g, k/g)*(x/g)%(k/g);
	if(y<n-1) y+=k;
	for(int i=1; i<n; i++){
		a[i]=1+(y-(n-1))/(n-1);
		if(i-1<y%(n-1)) a[i]++;
	}
	cout<<n<<" "<<m<<" "<<k<<endl;
	cout<<"*";
	for(int i=0; i<m; i++) cout<<" "<<b[i];
	cout<<endl;
	for(int i=0; i<n; i++) cout<<a[i]<<endl;
	return 0;
}
0