Topic
1177. Square
Time limit:1000MS memory limit:64000KB
Title description again to summer vacation, Conan, Ayumi, Mitsuhiko, Genta together to Hakase home happy play (but you do not ...). )。
Ayumi, Mitsuhiko, Genta began to draw a square in turn (obviously AI will not participate in this activity), one person a pen, draw one, to the last square four-sided midpoint for the vertex and then draw ah painting ah painting ah ... Finally altogether the K-squares were drawn. In the end they wanted to know how long they had painted each.
"Sample Interpretation"
The input input line contains two integer n,k that represent the length of the first square and the number of squares. Output one line, three real numbers, respectively, representing Ayumi, Mitsuhiko, Genta the length of the painting, the answer is reserved 3 decimal places. Input sampleCopy100 2 Output ExampleCopy270.711 241.421 170.711 explains "data size and conventions" for 100% of data satisfaction. 、Analysis Law problem ...
Each person will do it at least once in each square.and then do one more time with the lawThe first one 1a second 2.... Code
1#include <bits/stdc++.h>2 using namespacestd;3 Doublea[Ten];4 intMain ()5 {6 intK,n;7Cin>>k>>N;8 Doublekk=K;9 intt=1;Ten for(intI=1; i<=n;i++) One { A if(t%4==0) -t=1; - if(i==1) the { -a[1]+=KK; -a[2]+=KK; -a[3]+=KK; +a[t]+=KK; -Kk/=2; +t++; A Continue; at } - Else - { -a[1]+=sqrt ((KK*KK) + (kk*kk)); -a[2]+=sqrt ((KK*KK) + (kk*kk)); -a[3]+=sqrt ((KK*KK) + (kk*kk)); inA[t]+=sqrt ((KK*KK) + (kk*kk)); - } tot++; +Kk=sqrt ((KK*KK) + (KK*KK))/2; - } theprintf"%.3f%.3f%.3f", a[1],a[2],a[3]); *}
October 22 Square