Submission #3590277
Source Code Expand
using System; using System.Linq;//リストの使用 using System.Collections.Generic; using System.Text;//テキストの高速出力に必要 class Program { static void Main() { string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。 long n = long.Parse(input[0]); long d = long.Parse(input[1]); long x = long.Parse(input[2]); float answer = 0; for(int i = 0; i < n; i++) { answer += (2*x + (4*i+1)*d)/4;//両方向の初項 answer += ProgressionTwo(0.5f, i)*(-2*d)/4;//左方向の中間項 answer += ProgressionOne(0.5f, i)*(2*x + 4*i*d - d)/4; answer += ProgressionZero(0.5f, i)*(x + 2*i*d)/4; answer += ProgressionTwo(0.5f, n-1-i)*(2*d)/4;//右方向の中間項 answer += ProgressionOne(0.5f, n-1-i)*(2*x + 4*i*d + 3*d)/4; answer += ProgressionZero(0.5f, n-1-i)*(x + d + 2*i*d)/4; answer += (2*i+1) * (x+i*d) / (4*DivideMod(2,i));//左の最終項 answer += (2*n-2*i-1) * (x+i*d+n*d) / (4*DivideMod(2,n-1-i));//右の最終項 } //Console.WriteLine(ProgressionZero(n,d)); //Console.WriteLine(ProgressionOne(n,d)); //Console.WriteLine(ProgressionTwo(n,d)); Console.WriteLine(answer); } static float ProgressionZero(float ratio, long n) {//等比数列の和 Σ(i=1~n)ratio^i = ratio + ratio^2 + ... + ratio^n if(n == 0) return 0;//項数が0の時 if(ratio == 1) return n;//公比が1の時 float product = DivideMod(ratio, n);//公比の項数乗 float answer = ratio * (1-product) / (1-ratio); return answer; } static float ProgressionOne(float ratio, long n) {//等差×等比数列の和 Σ(i=1~n)i*ratio^i = 1*ratio + 2+ratio^2 + ... + n*ratio^n if(n == 0) return 0;//項数が0の時 if(ratio == 1) return n*(n+1)/2;//公比が1の時 float product = DivideMod(ratio, n);//公比の項数乗 float answer = ratio * (1-product) / (1-ratio); answer -= n*product*ratio; answer /= 1-ratio; return answer; } static float ProgressionTwo(float ratio, long n) {//(等差)^2×等比数列の和 Σ(i=1~n)i^2*ratio^i = 1^2*ratio + 2^2+ratio^2 + ... + n^2*ratio^n if(n == 0) return 0;//項数が0の時 if(ratio == 1) return n*(n+1)*(2*n+1)/6;//公比が1の時 float product = DivideMod(ratio, n);//公比の項数乗 float answer = 2 * ratio * (1-product) / (1-ratio); answer -= ratio; answer -= n*n*ratio*product; answer += n*n*ratio*ratio*product; answer -= (2*n-1)*ratio*product; answer /= ratio*ratio - 2*ratio + 1; return answer; } static float DivideMod(float x, long a)//戻り値はx^a、ただしaは整数。 { long num = 2; float answer = 1; long check = a; float memo = x; while(check > 0) { if(check % num == num / 2) { check -= num / 2; answer *= memo; } memo *= memo; num *= 2; } return answer; } }
Submission Info
Submission Time | |
---|---|
Task | C - Pushing Balls |
User | suikameron |
Language | C# (Mono 4.6.2.0) |
Score | 0 |
Code Size | 3067 Byte |
Status | WA |
Exec Time | 1008 ms |
Memory | 13140 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1000 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt, example2.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, example0.txt, example1.txt, example2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | WA | 20 ms | 9044 KB |
001.txt | WA | 20 ms | 9044 KB |
002.txt | WA | 20 ms | 9044 KB |
003.txt | WA | 20 ms | 9044 KB |
004.txt | WA | 21 ms | 11092 KB |
005.txt | WA | 20 ms | 9044 KB |
006.txt | WA | 20 ms | 9044 KB |
007.txt | WA | 21 ms | 11092 KB |
008.txt | WA | 21 ms | 11092 KB |
009.txt | WA | 20 ms | 9044 KB |
010.txt | WA | 129 ms | 11092 KB |
011.txt | WA | 824 ms | 11092 KB |
012.txt | WA | 448 ms | 11092 KB |
013.txt | WA | 540 ms | 11092 KB |
014.txt | WA | 377 ms | 11092 KB |
015.txt | WA | 909 ms | 11092 KB |
016.txt | WA | 845 ms | 9044 KB |
017.txt | WA | 354 ms | 9044 KB |
018.txt | WA | 877 ms | 9044 KB |
019.txt | WA | 176 ms | 11092 KB |
020.txt | WA | 1006 ms | 11092 KB |
021.txt | WA | 1006 ms | 11092 KB |
022.txt | WA | 1006 ms | 11092 KB |
023.txt | WA | 1006 ms | 11092 KB |
024.txt | WA | 1006 ms | 9044 KB |
025.txt | WA | 1006 ms | 9044 KB |
026.txt | WA | 1006 ms | 11092 KB |
027.txt | WA | 1006 ms | 11092 KB |
028.txt | WA | 1006 ms | 9044 KB |
029.txt | WA | 1005 ms | 9044 KB |
030.txt | WA | 1008 ms | 9044 KB |
031.txt | WA | 1007 ms | 13140 KB |
example0.txt | WA | 21 ms | 11092 KB |
example1.txt | WA | 21 ms | 11092 KB |
example2.txt | WA | 24 ms | 11092 KB |