luogu P1424

小鱼的航程(改进版)

30分没错~~O(≧口≦)O~~( ⊙ o ⊙ )啊!

看看我的30分代码啦

#include<iostream>
#include<cstdio>

using namespace std;

long int n;
int main()
{
	int x,l=0;
	cin>>x>>n;
	if((n-x+2)%7==1)
	{
		l=(n-x)/7;
		cout<<(n-2*l-1)*250<<endl;
	}
	else
	{
		l=(n-x)/7;
		cout<<(n-2*l)*250<<endl;
	}
	
	return 0;
}

  题解的100分,用加法很妙啊!

#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
	unsigned long long n,ans=0;
	int x;
	cin>>x>>n;
	for(int i=1;i<=n;i++)
	{
		if((x!=6)&&(x!=7))
		ans+=250;
		if(x==7)
		x=1;
		else
		x++;
	}
	cout<<ans<<endl;
	return 0;
}

  

猜你喜欢

转载自www.cnblogs.com/xrj1229/p/9240191.html