結果
| 問題 | No.316 もっと刺激的なFizzBuzzをください |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-01-19 21:38:18 |
| 言語 | Java (openjdk 23) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,244 bytes |
| コンパイル時間 | 2,843 ms |
| コンパイル使用メモリ | 81,724 KB |
| 実行使用メモリ | 82,860 KB |
| 最終ジャッジ日時 | 2024-12-23 01:35:49 |
| 合計ジャッジ時間 | 46,340 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 TLE * 1 |
| other | AC * 18 TLE * 15 |
ソースコード
import java.util.Scanner;
import java.util.stream.IntStream;
/**
* Created by nullzine on 2017/01/19.
*/
public class Main {
public static void main(String[] args){
new Main().run2();
}
private void run(){
Scanner sc = new Scanner(System.in);
int n = Integer.parseInt(sc.nextLine());
String[] strs = sc.nextLine().split(" ");
int a=Integer.parseInt(strs[0]),b=Integer.parseInt(strs[1]),c=Integer.parseInt(strs[2]);
System.out.println(IntStream.range(1,n+1).parallel().filter(f -> f % a == 0 || f % b == 0 || f % c == 0).toArray().length);
}
private void run2(){
Scanner sc = new Scanner(System.in);
int n = Integer.parseInt(sc.nextLine());
String[] strs = sc.nextLine().split(" ");
int a=Integer.parseInt(strs[0]),b=Integer.parseInt(strs[1]),c=Integer.parseInt(strs[2]);
Count count = new Count();
IntStream.range(1,n+1).parallel().forEach(e->{
if(e % a == 0 || e % b == 0 || e % c == 0){
synchronized (count){
count.count++;
}
}
});
System.out.println(count.count);
}
class Count{
public int count=0;
}
}