結果

問題 No.1233 割り切れない気持ち
ユーザー 37zigen37zigen
提出日時 2020-09-21 06:05:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 789 ms / 3,153 ms
コード長 711 bytes
コンパイル時間 4,966 ms
コンパイル使用メモリ 73,444 KB
実行使用メモリ 74,140 KB
最終ジャッジ日時 2023-09-06 16:56:07
合計ジャッジ時間 31,727 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
62,344 KB
testcase_01 AC 134 ms
62,252 KB
testcase_02 AC 153 ms
62,520 KB
testcase_03 AC 233 ms
63,636 KB
testcase_04 AC 244 ms
63,404 KB
testcase_05 AC 164 ms
61,924 KB
testcase_06 AC 154 ms
62,456 KB
testcase_07 AC 492 ms
67,592 KB
testcase_08 AC 553 ms
67,300 KB
testcase_09 AC 705 ms
71,960 KB
testcase_10 AC 700 ms
71,880 KB
testcase_11 AC 444 ms
67,528 KB
testcase_12 AC 789 ms
71,596 KB
testcase_13 AC 748 ms
71,568 KB
testcase_14 AC 775 ms
71,504 KB
testcase_15 AC 740 ms
71,676 KB
testcase_16 AC 774 ms
71,440 KB
testcase_17 AC 591 ms
71,712 KB
testcase_18 AC 743 ms
71,776 KB
testcase_19 AC 716 ms
71,840 KB
testcase_20 AC 593 ms
74,140 KB
testcase_21 AC 621 ms
71,824 KB
testcase_22 AC 616 ms
71,484 KB
testcase_23 AC 617 ms
71,548 KB
testcase_24 AC 623 ms
71,644 KB
testcase_25 AC 608 ms
71,496 KB
testcase_26 AC 619 ms
71,896 KB
testcase_27 AC 631 ms
71,648 KB
testcase_28 AC 634 ms
71,560 KB
testcase_29 AC 636 ms
72,024 KB
testcase_30 AC 624 ms
71,432 KB
testcase_31 AC 631 ms
71,828 KB
testcase_32 AC 632 ms
71,712 KB
testcase_33 AC 629 ms
71,740 KB
testcase_34 AC 659 ms
71,476 KB
testcase_35 AC 639 ms
71,620 KB
testcase_36 AC 630 ms
71,672 KB
testcase_37 AC 143 ms
62,088 KB
testcase_38 AC 594 ms
71,808 KB
testcase_39 AC 739 ms
71,832 KB
testcase_40 AC 746 ms
71,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;

class Main {
	public static void main(String[] $) {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] A=new int[1<<20];
		int[] s=new int[1<<20];
		long ans=0;
		for (int i=0;i<N;++i) {
			int a=sc.nextInt();
			s[a]++;
			ans+=1L*a*N;
			A[a]++;
		}
		for (int i=s.length-2;i>=0;--i) {
			s[i]+=s[i+1];
		}
		for (int i=0;i<A.length;++i) {
			if (A[i]==0) continue;
			for (int a=i;a<s.length;a+=i) {
				ans-=1L*s[a]*i*A[i];
			}
		}
		System.out.println(ans);
		
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}
0