結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー fgwiebfaoishfgwiebfaoish
提出日時 2019-10-12 00:57:35
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 25 ms / 1,000 ms
コード長 2,734 bytes
コンパイル時間 2,748 ms
コンパイル使用メモリ 115,504 KB
実行使用メモリ 26,324 KB
最終ジャッジ日時 2024-05-04 11:54:48
合計ジャッジ時間 4,450 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
24,164 KB
testcase_01 AC 21 ms
21,808 KB
testcase_02 AC 21 ms
24,028 KB
testcase_03 AC 21 ms
24,032 KB
testcase_04 AC 22 ms
26,024 KB
testcase_05 AC 21 ms
26,072 KB
testcase_06 AC 21 ms
23,984 KB
testcase_07 AC 22 ms
25,896 KB
testcase_08 AC 23 ms
26,324 KB
testcase_09 AC 22 ms
24,100 KB
testcase_10 AC 25 ms
23,984 KB
testcase_11 AC 22 ms
24,116 KB
testcase_12 AC 22 ms
23,988 KB
testcase_13 AC 22 ms
25,900 KB
testcase_14 AC 22 ms
24,156 KB
testcase_15 AC 21 ms
22,192 KB
testcase_16 AC 22 ms
22,200 KB
testcase_17 AC 20 ms
23,732 KB
testcase_18 AC 21 ms
26,028 KB
testcase_19 AC 21 ms
23,776 KB
testcase_20 AC 22 ms
23,980 KB
testcase_21 AC 21 ms
23,864 KB
testcase_22 AC 21 ms
23,864 KB
testcase_23 AC 22 ms
26,272 KB
testcase_24 AC 21 ms
24,032 KB
testcase_25 AC 22 ms
24,156 KB
testcase_26 AC 21 ms
23,516 KB
testcase_27 AC 21 ms
23,856 KB
testcase_28 AC 22 ms
24,032 KB
testcase_29 AC 22 ms
24,160 KB
testcase_30 AC 21 ms
23,792 KB
testcase_31 AC 22 ms
24,024 KB
testcase_32 AC 20 ms
22,064 KB
testcase_33 AC 20 ms
26,024 KB
testcase_34 AC 21 ms
21,812 KB
testcase_35 AC 20 ms
23,864 KB
testcase_36 AC 21 ms
23,908 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;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.La;
		long ans=n/a[0];
		if(a[1]%a[0]!=0){
			ans+=n/a[1];
			ans-=n/(a[0]*a[1]/Gcd(a[0],a[1]));
			if(a[2]%a[0]!=0&&a[2]%a[1]!=0){
				ans+=n/a[2];
				ans-=n/(a[0]*a[2]/Gcd(a[0],a[2]));
				var g=a[1]*a[2]/Gcd(a[1],a[2]);
				ans-=n/g;
				ans+=n/(a[0]*g/Gcd(a[0],g));
			}
		}
		else if(a[2]%a[0]!=0){
			ans+=n/a[2];
			ans-=n/(a[0]*a[2]/Gcd(a[0],a[2]));
		}
		Console.WriteLine("{0}",ans);
	}
	static long Gcd(long a,long b){
		long c=Math.Max(a,b)%Math.Min(a,b);
		b=Math.Min(a,b);
		while(c!=0){
			a=b%c;
			b=c;
			c=a;
		}
		return b;
	}
}

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