警示后人
查看原帖
警示后人
1132339
SIRIUS0105楼主2024/1/11 16:49

下面你可以看到一只蒟蒻的80分代码

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int s, v0, v1, t1, v2, t2;
	cin >> s >> v0 >> v1 >> t1 >> v2 >> t2;
	
	int n;
	cin >> n;
	
	int npos = 0;
	int ntime = 0;
	for(int i=0;i<n;i++)
	{
		int t;
		int time;
		cin >> t;
		t = t-ntime;
		time = ceil(1.0*(s-npos) / v0);
		if(1ll*(npos + v0*t)>= 1ll*s)
		{
			npos = s;
			ntime+=time;
			break;
		}
		else
		{
			npos = npos+v0*t;
			ntime+=t;
		}
		long long temp;
		temp = (v1+v2*i)*(t1+t2*i);
		npos = npos - temp;
		if(npos<0)
		{
			npos = 0;
		}
		ntime+=t1+t2*i;
	}
	
	if (npos < s)
    {
        ntime = ceil(ntime + 1.0*(s-npos)/v0);
    }
	
	int nday, nhour, nminute, nsecond;
	if(ntime>=3600*24*30)
	{
		nday  = 30;
		nhour = 23;
		nminute = 59;
		nsecond = 59;
		
	}
	else
	{
		nsecond = ntime%60;
		nminute = (ntime%3600)/60;
		nhour   = (ntime%86400)/3600;
		nday    = ntime/86400+1;
	}
	printf("202304%02dat%02d:%02d:%02d\n", nday, nhour, nminute, nsecond);
	return 0;
} 

(非常的可恶)


但是如果这样(如下)

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int s, v0, v1, t1, v2, t2;
	cin >> s >> v0 >> v1 >> t1 >> v2 >> t2;
	
	int n;
	cin >> n;
	
	long long npos = 0;
	int ntime = 0;
	for(int i=0;i<n;i++)
	{
		int t;
		int time;
		cin >> t;
		t = t-ntime;
		time = ceil(1.0*(s-npos) / v0);
		if(1ll*(npos + v0*t)>= 1ll*s)
		{
			npos = s;
			ntime+=time;
			break;
		}
		else
		{
			npos = npos+v0*t;
			ntime+=t;
		}
		long long temp;
		temp = (v1+v2*i)*(t1+t2*i);
		npos = npos - temp;
		if(npos<0)
		{
			npos = 0;
		}
		ntime+=t1+t2*i;
	}
	
	if (npos < s)
    {
        ntime = ceil(ntime + 1.0*(s-npos)/v0);
    }
	
	int nday, nhour, nminute, nsecond;
	if(ntime>=3600*24*30)
	{
		nday  = 30;
		nhour = 23;
		nminute = 59;
		nsecond = 59;
		
	}
	else
	{
		nsecond = ntime%60;
		nminute = (ntime%3600)/60;
		nhour   = (ntime%86400)/3600;
		nday    = ntime/86400+1;
	}
	printf("202304%02dat%02d:%02d:%02d\n", nday, nhour, nminute, nsecond);
	return 0;
} 

很神奇地AC了哎

错误原因;没开long long!!!

2024/1/11 16:49
加载中...