結果
| 問題 |
No.413 +5,000,000pts
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-06-06 21:08:07 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,933 bytes |
| コンパイル時間 | 2,448 ms |
| コンパイル使用メモリ | 81,520 KB |
| 実行使用メモリ | 46,968 KB |
| 最終ジャッジ日時 | 2024-10-12 02:22:58 |
| 合計ジャッジ時間 | 3,693 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 1 |
ソースコード
package yukicoder;
import java.math.BigDecimal;
import java.util.ArrayList;
public class Main{
public static void main(String[] args) {
new Main().solve();
}
void solve() {
int count=0;
ArrayList<Long> used=new ArrayList<>();
for(long i=1_000_000_000L;i>=1;i--){
if(i*(i+1)<1_000_000_000_000_000_000L){
long d=i*(i+1)-1;
while(!iscorrect(d,calc(d))){
if(used.contains(d))continue;
System.out.println(d);
used.add(d);
d--;
count++;
if(count==10000)return;
}
}
}
}
boolean iscorrect(long d, long ans) {
if (ans * ans + ans <= d && (ans + 1) * (ans + 1) + (ans + 1) > d) {
return true;
} else
return false;
}
long calc(long d) {
return (long) ((-1 + Math.sqrt(1 + 4 * d)) / 2.0);
}
double calc_ori(long d) {
return (-1 + Math.sqrt(1 + 4 * d)) / 2.0;
}
BigDecimal calc_ori_ex(long d) {
return BigDecimal.valueOf(-1).add(sqrt(BigDecimal.valueOf(4 * d + 1), 100)).divide(BigDecimal.valueOf(2));
}
void show(long d) {
System.out.println("参加者の示すtの値" + calc(d));
System.out.println("t*t+t " + (calc(d) * calc(d) + calc(d)));
System.out.println("(t+1)(t+1)+(t+1)" + ((calc(d) + 1) * (calc(d) + 1) + (calc(d) + 1)));
System.out.println("d " + d);
System.out.println("二次方程式を解いた時のtの値(参加者の)" + calc_ori(d));
System.out.println("二次方程式を解いた時のt(参加者の)でのt*t+t" + (calc_ori(d) * calc_ori(d) + calc_ori(d)));
System.out.println("二次方程式を解いた時のtの値(精度を上げた)" + calc_ori_ex(d));
}
// scaleは桁数。
public static BigDecimal sqrt(BigDecimal a, int scale) {
BigDecimal x = a;
for (int i = 0; i < 10000; i++) {
// x=x-(x*x-a)/(2*x)
x = x.subtract((x.multiply(x).subtract(a)).divide((x.multiply(BigDecimal.valueOf(2.0))), scale,
BigDecimal.ROUND_HALF_EVEN));
}
return x;
}
}