結果
| 問題 |
No.473 和と積の和
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2016-12-23 04:11:24 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,398 bytes |
| コンパイル時間 | 1,310 ms |
| コンパイル使用メモリ | 114,736 KB |
| 実行使用メモリ | 45,824 KB |
| 最終ジャッジ日時 | 2024-12-16 03:05:22 |
| 合計ジャッジ時間 | 53,102 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 TLE * 1 |
| other | AC * 32 TLE * 11 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class TEST{
static void Main(){
Sol mySol =new Sol();
mySol.Solve();
}
}
class Sol{
public void Solve(){
HashSet<MSet> H = new HashSet<MSet>();
var pp = new MSet();
pp.Add(X);
H.Add(pp);
for(int i=1;i<N;i++){
HashSet<MSet> nxt = new HashSet<MSet>();
foreach(var p in H){
for(int j=0;j<p.Count;j++){
if(j>0 && p[j] == p[j-1]) continue;
int k = p[j];
for(int t=2;t*t<=k+1;t++){
if((k+1)%t != 0) continue;
var q = new MSet(p);
q.Push(t-1,(k+1)/t-1,j);
nxt.Add(q);
}
}
}
H = nxt;
}
Console.WriteLine(H.Count);
}
class MSet{
public List<int> L;
int hash;
public int Count{
get{ return L.Count;}
}
public MSet(IEnumerable<int> l){
L = new List<int>(l);
L.Sort();
hash = L.Aggregate( (s,t) => s^t );
}
public MSet(){
L = new List<int>();
hash = 0;
}
public MSet(MSet p){
L = new List<int>(p.L);
hash = p.hash;
}
public int this[int idx]{
get {return L[idx];}
}
public void Add(int x){
L.Add(x);
L.Sort();
hash ^= x;
}
public void Push(int x,int y,int idx){
L[idx] = x;
L.Add(y);
L.Sort();
}
public override bool Equals(System.Object obj){
if(obj == null) return false;
MSet p = (MSet) obj;
if((System.Object) p == null ) return false;
return chkEqual(p);
}
bool chkEqual(MSet p){
if(p.Count != L.Count)return false;
for(int i=0;i<L.Count;i++){
if(p.L[i] != L[i]) return false;
}
return true;
}
public override int GetHashCode(){
return hash;
}
}
int N;
int X;
public Sol(){
var d = ria();
N = d[0]; X = d[1];
}
static String rs(){return Console.ReadLine();}
static int ri(){return int.Parse(Console.ReadLine());}
static long rl(){return long.Parse(Console.ReadLine());}
static double rd(){return double.Parse(Console.ReadLine());}
static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
kuuso1