1 solutions
-
0
C++ :
#include<bits/stdc++.h> using namespace std; long long n,k,t; int main() { cin>>n; while(n--) { long long a=0,b=0,c=0; cin>>k; if(k==1)cin>>a>>b,t+=(a+b)*2; if(k==2)cin>>a,t+=a*4; if(k==3)cin>>a>>b>>c,t+=a+b+c; } cout<<t; return 0; }Pascal :
var k,i,n:longint;a,b,c,s:int64; begin read(n); for i:=1 to n do begin read(k); case k of 1:begin read(a); read(b); end; 2:read(a); 3:begin read(a); read(b); read(c); end; end; case k of 1:s:=s+a*2+b*2; 2:s:=s+a*4; 3:s:=s+a+b+c; end; end; write(s); end.
- 1
Information
- ID
- 17364
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By