Pls ajutor la #2979 si #2766 de pe pbinfo
Răspunsuri la întrebare
//2979
#include <fstream>
using namespace std;
ifstream f("cartele.in");
ofstream g("cartele.out");
int maxim,sec1,sec,p,h,m,s,h1,m1,s1,i,N,max1,cb,cf,suma;
char c,a;
int main()
{
f>>p;
f>>N;
if (p==1)
{
cb=0;
cf=0;
for (i = 1; i <= N; i++)
{
f>>c>>a>>h>>m>>s;
if (c=='b')
if (a=='i') cb++;
else cb--;
else
if (a=='i') cf++;
else cf--;
}
g<<cb<<" "<<cf<<"\n";
}
else
if (p==2)
{
f>>c>>a>>h1>>m1>>s1;
sec1=h1*3600+m1*60+s1;
if (c=='b') cb=1,cf=0;
else cb=0,cf=1;
suma=0;
for (i = 2; i <= N; i++)
{
f>>c>>a>>h>>m>>s;
sec=h*3600+m*60+s;
if (cb==cf && cb>0) suma += (sec-sec1);
if (c=='b')
if (a=='i') cb++;
else cb--;
else
if (a=='i') cf++;
else cf--;
sec1=sec;
}
g<<suma<<"\n";
}
else
{
f>>c>>a>>h1>>m1>>s1;
if (c=='b') {cb=1;cf=0;sec1=h1*3600+m1*60+s1;}
else cb=0,cf=1;
maxim=0;
for (i = 2; i <= N; i++)
{
f>>c>>a>>h>>m>>s;
sec=h*3600+m*60+s;
if (c=='b')
{
if (cb%2!=0 && sec-sec1 > maxim) maxim=sec-sec1;
if (a=='i') cb++;
else cb--;
sec1=sec;
}
else
if (a=='i') cf++;
else cf--;
}
g<<maxim<<"\n";
}
return 0;
}
///////////////////////
//2766
#include <iostream>
using namespace std;
int main()
{
int r1, r2, g1, g2, b1, b2, n, i;
cin >> r1 >> g1 >> b1 >> r2 >> g2 >> b2 >> n;
int dr, dg, db;
dr = r2-r1;
dg = g2-g1;
db = b2-b1;
cout << r1 << ", " << g1 << ", " << b1 << '\n';
--n;
for(i = 1; i <= n; ++i)
cout << (int)(r1+dr*i/(double)n) << ", " << (int)(g1+dg*i/(double)n) << ", " << (int)(b1+db*i/(double)n) << '\n';
return 0;
}