Задача A-Куб Березін Дмитро Var n:longint; all,one,two,three,none:int64; Begin Readln(n); all:=n*n;all:=all*n; three:=8; one:=6*(n-2)*(n-2); none:=2*n*n;none:=none+2*(n-2)*n;none:=none+2*(n-2)*(n-2);none:=all-none; two:=all-three-one-none; Writeln(three,' ',two,' ',one,' ',none); End.
Задача B-Сума коефіцієнтів Савчук Владислав Var a:array[0..1000] of longint; n,i,l,j,o,k:longint; Begin Readln(n); a[0]:=1; a[1]:=2; For k:=1 to n-1 do Begin For i:=1 to a[0] do a[i]:=a[i]*3; if k mod 2=0 then a[1]:=a[1]+2 else a[1]:=a[1]-2;
For i:=1 to a[0] do if a[i]<0 then Begin a[i]:=a[i]+10; a[i+1]:=a[i+1]-1; end; For i:=1 to a[0] do Begin a[i+1]:=a[i+1]+a[i] div 10; a[i]:=a[i] mod 10; end; l:=a[0]; While a[l+1]<>0 do Begin inc(h); a[l+1]:=a[l+1]+a[l] div 10; a[l]:=a[l] mod 10; end; a[0]:=l; end; if n mod 2=0 then Write('-'); For i:=l downto 1 do if a[i]<>0 then Begin l:=i; break; end; For i:=l downto 1 do Write(a[i]); End.
Задача C-Труба часу Франчук Роман #include <iostream> #include <vector> #include <list> using namespace std; struct edge { int x,y,t; }; edge make_edge(int x,int y,int t){edge tmp;tmp.x=x;tmp.y=y;tmp.t=t;return tmp;} list<edge> g; bool fba(int n) { vector<int> d(n,2000000000); d[0]=0; for(int i=0;i<n;i++) { bool chng=false; for(list<edge>::iterator p=g.begin();p!=g.end();p++) if(d[p->y]>d[p->x]+p->t) { chng=true; d[p->y]=d[p->x]+p->t; } if(!chng)return false; } return true; } void processTest() { int n,m;cin>>n>>m; g.clear(); for(int i=0;i<m;i++) { int x,y,t;cin>>x>>y>>t; g.push_back(make_edge(x,y,t)); } if(fba(n))cout<<"Yes\n";else cout<<"No\n"; } int main() { int k;cin>>k; for(int i=0;i<k;i++) { processTest(); } return 0; }