文章

50

粉丝

0

获赞

54

访问

1.5k

头像
Old Bill 题解:for(for and mind the corner case
P1274 上海交通大学机试题
发布于2026年3月12日 13:37
阅读数 12

#include <iostream>
using namespace std;

int main()
{
	int N;
	while(cin>>N)
	{
		int x,y,z;
		cin>>x>>y>>z;
		int maxprice=0;
		int first=0;
		int last=0;
		for(int i=1;i<10;i++)
			for(int j=0;j<10;j++)
			{
				int guess=i*10000+x*1000+y*100+z*10+j;
				if(guess%N==0)
					if(guess/N>maxprice)
					{
						maxprice=guess/N;
						first=i;
						last=j;
					}
			}
		if(maxprice)
			cout<<first<<" "<<last<<" "<<maxprice<<endl;
		else
			cout<<"0"<<endl;
	}
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发