結果

問題 No.1017 Reiwa Sequence
ユーザー fgwiebfaoishfgwiebfaoish
提出日時 2020-06-18 16:59:06
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 546 ms / 2,000 ms
コード長 3,412 bytes
コンパイル時間 4,957 ms
コンパイル使用メモリ 109,888 KB
実行使用メモリ 50,916 KB
最終ジャッジ日時 2023-09-16 12:11:54
合計ジャッジ時間 25,040 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
22,352 KB
testcase_01 AC 65 ms
21,996 KB
testcase_02 AC 69 ms
22,056 KB
testcase_03 AC 70 ms
22,404 KB
testcase_04 AC 68 ms
22,076 KB
testcase_05 AC 71 ms
22,128 KB
testcase_06 AC 70 ms
22,272 KB
testcase_07 AC 70 ms
24,044 KB
testcase_08 AC 71 ms
22,120 KB
testcase_09 AC 71 ms
22,384 KB
testcase_10 AC 107 ms
28,768 KB
testcase_11 AC 71 ms
22,436 KB
testcase_12 AC 461 ms
50,076 KB
testcase_13 AC 458 ms
50,916 KB
testcase_14 AC 67 ms
22,280 KB
testcase_15 AC 67 ms
22,300 KB
testcase_16 AC 66 ms
20,252 KB
testcase_17 AC 71 ms
24,488 KB
testcase_18 AC 68 ms
24,504 KB
testcase_19 AC 208 ms
30,628 KB
testcase_20 AC 211 ms
32,716 KB
testcase_21 AC 207 ms
27,640 KB
testcase_22 AC 205 ms
28,732 KB
testcase_23 AC 208 ms
29,672 KB
testcase_24 AC 206 ms
27,668 KB
testcase_25 AC 204 ms
27,688 KB
testcase_26 AC 206 ms
27,436 KB
testcase_27 AC 128 ms
30,860 KB
testcase_28 AC 110 ms
28,680 KB
testcase_29 AC 143 ms
30,864 KB
testcase_30 AC 157 ms
27,660 KB
testcase_31 AC 109 ms
28,708 KB
testcase_32 AC 109 ms
29,652 KB
testcase_33 AC 110 ms
27,276 KB
testcase_34 AC 108 ms
26,748 KB
testcase_35 AC 106 ms
26,600 KB
testcase_36 AC 109 ms
27,300 KB
testcase_37 AC 106 ms
26,776 KB
testcase_38 AC 109 ms
28,696 KB
testcase_39 AC 108 ms
27,460 KB
testcase_40 AC 502 ms
45,796 KB
testcase_41 AC 498 ms
45,832 KB
testcase_42 AC 498 ms
45,704 KB
testcase_43 AC 501 ms
44,732 KB
testcase_44 AC 487 ms
35,484 KB
testcase_45 AC 526 ms
45,944 KB
testcase_46 AC 502 ms
44,708 KB
testcase_47 AC 510 ms
39,268 KB
testcase_48 AC 546 ms
50,516 KB
testcase_49 AC 513 ms
43,144 KB
testcase_50 AC 516 ms
44,432 KB
testcase_51 AC 52 ms
18,696 KB
testcase_52 AC 147 ms
30,744 KB
testcase_53 AC 141 ms
30,828 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
//using nint=System.Int32;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		if(n==1){
			Console.WriteLine("No");
			return;
		}
		var a=sc.Ia;
		int m=Min(n,22);
		var b=new int[m>>1];
		var c=new int[m-(m>>1)];
		for(int i = 0;i<m>>1;i++) {b[i]=a[i];}
		for(int i = m>>1;i<m;i++) {c[i-(m>>1)]=a[i];}
		int g=(int)Pow(3,b.Length);
		var hs=new Dictionary<int,string>();
		for(int i = 0;i<g;i++) {
			var t=Pn(i,3,b.Length);
			int p=0;
			for(int j = 0;j<t.Length;j++) {p+=b[j]*((t[j]+1)%3-1);}
			if(!hs.ContainsKey(p)){hs.Add(p,t);}
			else if(long.Parse(hs[p])==0){hs[p]=t;} 
		}
		g=(int)Pow(3,c.Length);
		for(int i = 0;i<g;i++) {
			var t=Pn(i,3,c.Length);
			int p=0;
			for(int j = 0;j<t.Length;j++) {p+=c[j]*((t[j]+1)%3-1);}
			if(hs.ContainsKey(-p)&&long.Parse(hs[-p])+long.Parse(t)!=0){
				t=hs[-p]+t;
				for(int j = 0;j<t.Length;j++) {a[j]*=(t[j]+1)%3-1;}
				for(int j = t.Length;j<n;j++) {a[j]=0;}
				Console.WriteLine("Yes");
				Console.WriteLine("{0}",String.Join(" ",a));
				return;
			}
		}
		Console.WriteLine("No");
	}
	static string Pn(int x,int n,int b){
		if(x==0){return new string('0',b);}
		var t="";
		var c=new char[]{'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
		int r=1;
		while(x>0){
			r=x%n;
			t+=c[r];
			x=x/n;
		}
		return (b>t.Length?new string('0',b-t.Length):"")+string.Join("",t.Reverse());
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}
0