結果

問題 No.944 煎っぞ!
ユーザー fgwiebfaoishfgwiebfaoish
提出日時 2019-12-07 08:47:17
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 106 ms / 3,000 ms
コード長 2,601 bytes
コンパイル時間 909 ms
コンパイル使用メモリ 64,448 KB
実行使用メモリ 34,480 KB
最終ジャッジ日時 2023-08-26 01:31:30
合計ジャッジ時間 5,797 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
32,328 KB
testcase_01 AC 102 ms
34,340 KB
testcase_02 AC 104 ms
32,292 KB
testcase_03 AC 103 ms
32,340 KB
testcase_04 AC 104 ms
32,532 KB
testcase_05 AC 103 ms
32,320 KB
testcase_06 AC 102 ms
32,292 KB
testcase_07 AC 102 ms
32,300 KB
testcase_08 AC 103 ms
34,452 KB
testcase_09 AC 102 ms
32,240 KB
testcase_10 AC 72 ms
22,972 KB
testcase_11 AC 78 ms
24,604 KB
testcase_12 AC 77 ms
23,824 KB
testcase_13 AC 66 ms
24,872 KB
testcase_14 AC 78 ms
24,408 KB
testcase_15 AC 75 ms
21,892 KB
testcase_16 AC 63 ms
22,656 KB
testcase_17 AC 63 ms
22,636 KB
testcase_18 AC 79 ms
26,428 KB
testcase_19 AC 78 ms
22,416 KB
testcase_20 AC 105 ms
30,700 KB
testcase_21 AC 105 ms
32,728 KB
testcase_22 AC 102 ms
32,112 KB
testcase_23 AC 103 ms
34,292 KB
testcase_24 AC 101 ms
32,200 KB
testcase_25 AC 102 ms
32,236 KB
testcase_26 AC 102 ms
32,236 KB
testcase_27 AC 104 ms
34,480 KB
testcase_28 AC 63 ms
22,788 KB
testcase_29 AC 64 ms
24,692 KB
testcase_30 AC 106 ms
32,764 KB
testcase_31 AC 105 ms
32,276 KB
testcase_32 AC 102 ms
34,232 KB
testcase_33 AC 106 ms
32,448 KB
testcase_34 AC 106 ms
32,560 KB
権限があれば一括ダウンロードができます

ソースコード

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;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.Ia2;
		var r=new int[n+1];
		var hs=new HashSet<int>();
		for(int i = 1;i<=n;i++) {
			r[i]=r[i-1]+a[i];
			hs.Add(r[i]);
		}
		int ans=0;
		Pn(r[n],(e)=>{
			int p=0;
			while(hs.Contains(p+e)){p+=e;}
			if(p==r[n]){ans=Max(ans,r[n]/e);}
		});
		Console.WriteLine("{0}",ans);
	}
	static void Pn(int n,Action<int> f){
		var q=Sqrt(n);
		for(int i = 1;i<q;i++) {if(n%i==0){f(i);f(n/i);}}
		if(n%q==0){f((int)q);}
	}
}

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(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.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