The first line of the input file contains an integer N (0<N<100), which represents the number of turkeys. In the following line, there are the three decimal digits X, Y, and Z., separated by a space, of the original price $_XYZ_.
For each case, output the two faded digits and the maximum price per turkey for the turkeys.
72 6 7 9 5 2 3 7 78 0 0 5
3 2 511 9 5 18475 0
#include <stdio.h>
int main()
{
int n, x, y, z, i, j, price;
scanf("%d%d%d%d", &n, &x, &y, &z);
for (i = 9; i > 0; i--)
for (j = 9; j >= 0; j--) {
price = i * 10000 + x * 1000 + y * 100 + z * 10 + j;
if (!(price % n)) {
printf("%d %d %d\n", i, j, price / n);
return 0;
}
}
printf("0\n");
return 0;
} #include<iostream>
using namespace std;
int main(){
int a[5];
int n;
while(cin>>n>>a[1]>>a[2]>>a[3]){
int total=0;
int b[20][2],count=0;
for(int i=1;i<=9;i++){
a[0]=i;
total=10000*a[0]+1000*a[1]+100*a[2]+10*a[3];
for(int j=0;j<=9;j++){
if((total+j)%n==0){
b[count][0]=a[0];
b[count++][1]=j;
}
}
}
if(count>0){
cout<<b[count-1][0]<<" "<<b[count-1][1]<<" ";
total=10000*b[count-1][0]+1000*a[1]+100*a[2]+10*a[3]+b[count-1][1];
cout<<total/n<<endl;
}
else cout<<0<<endl;
}
}
#因为要找到最大的火鸡单价,所以从最大的火鸡总价开始找
while True:
try:
numTurkey = int(input())
midNum = int(input().replace(' ',''))
whetherFind = False #设置一个bool值来确认是否找到
for i in range(9,0,-1): #最高位不能为0
for j in range(9,-1,-1):
tempTotal = i*10000+midNum*10+j
if tempTotal % numTurkey == 0:
leftNum = i
rightNum = j
whetherFind = True
price = tempTotal//numTurkey
break
if whetherFind:
break
if whetherFind:
print('%d %d %d'%(leftNum,rightNum,price))
else: #未找到输出为0
print(0)
except Exception:
break #include <iostream>
using namespace std;
int main(){
int n;
while(cin>>n){
int d[3];
for(int i=0;i<3;i++){
cin>>d[i];
}
int max=0;
int m=0;
int start=0;
int end=0;
for(int i=1;i<=9;i++){
for(int j=0;j<=9;j++){
m=i*10000+d[0]*1000+d[1]*100+d[2]*10+j;
if(max<m && m%n==0){
max=m;
start=i;
end=j;
}
}
}
if(max==0){
cout<<0<<endl;
}else
cout<<start<<" "<<end<<" "<<max/n<<endl;
}
} #include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int n;
int digits[5];
int getNum() { int ret = 0; int c = 1; for (int i = 4; i >= 0; i--) { ret += digits[i]*c; c *= 10; } return ret;
}
int main()
{ while (cin >> n) { cin >> digits[1] >> digits[2] >> digits[3]; int flag = true; for (int i = 9; i > 0&&flag; i--) { for (int j = 9; j >= 0&&flag; j--) { digits[0] = i; digits[4] = j; int num = getNum(); if (num%n == 0) { cout << i << " " << j << " " << num / n<<endl; flag = false; break; } } } if (flag) { cout << 0 << endl; } }
return 0;
}
__author__ = 'Yaicky'
while True:
try:
n = input()
qian, bai, shi = map(int, raw_input().strip().split())
wan, ge, price = 0, 0, 0
flag = True
while flag:
for i in range(9, 0,-1):
num = i*10000 + qian*1000 + bai*100 + shi*10 + 9
rest = num%n
if rest < 10:
price = (num - rest)/n
wan = i
ge = 9 - rest
flag = False
break
if i == 1:
flag = False
#print n, qian,bai,shi
if price == 0:
print '0'
else:
print "%d %d %d" %(wan, ge, price)
except:
break
#include<iostream>
#include<cstring>
using namespace std;
int fun(int N, int X, int Y, int Z) {
bool find = false;
int sum = 0;
for (int i = 9; i >= 1; i--) {
for (int j = 9; j >= 0; j--) {
sum = i * 10000 + X * 1000 + Y * 100 + Z * 10 + j;
if (sum%N == 0) {
find = true;
cout << i << " " << j << " " << (sum / N) << endl;
return 0;
}
}
}
if (!find) {
cout << 0 << endl;
}
return 0;
}
int main() {
int N, X, Y, Z;
while (cin >> N >> X >> Y >> Z) {
fun(N, X, Y, Z);
}
return 0;
} #include <stdio.h>
#include <stdlib.h>
int main(){
int n,x,y,z;
while((scanf("%d%d%d%d",&n,&x,&y,&z))!=EOF){
int i=0,j=0,num=0,value = 0,ci=0,cj=0;
num+=(1000*x+100*y+10*z);
for(i=1;i<10;++i)
for(j=0;j<10;++j){
value=(num+10000*i+j);
if(value%n==0){
ci=i;
cj=j;
}
}
if(ci==0&&cj==0)
printf("0\n");
else
printf("%d %d %d\n",ci,cj,(num+10000*ci+cj)/n);
}
return 0;
}
/*一些人生经验,记得加\n,少用全局变量,需要直接定义值的时候直
接赋值少用+=,注意每个变量的初始化时间*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,x,y,z;
while(cin>>n)
{
cin>>x>>y>>z;
int temp = x*1000+y*100+z*10;
int total; //记录总价格
int MAX = -99999; //记录蕞大价格
bool find = false; //是否有符合条件的结果
int first,last; // 第一位 与 最后一位
for(int i=1;i<10;i++)
{
for(int j=0;j<10;j++)
{
total = temp + 10000*i + j;
if(total%n==0)
{
find = true;
if(total/n>MAX)
{
MAX = total/n;
first = i;
last = j;
}
}
}
}
if(!find)
{
cout<<0<<endl;
}else{
cout<<first<<" "<<last<<" "<<MAX<<endl;
}
}
return 0;
}
#include<stdio.h>
int main(){
int n;
while(scanf("%d",&n)!=EOF){
int a,b,c,flag=0;
scanf("%d%d%d",&a,&b,&c);
for(int i=9;i>=1;i--)
{
for(int j=9;j>=0;j--)
{
int m=i*10000+a*1000+b*100+c*10+j;
if(m%n==0)
{
printf("%d %d %d\n",i,j,m/n);
flag=1;
break;
}
}
if(flag==1) break;
}
if(flag==0) printf("0\n");
}
return 0;
}
#include <stdio.h>
int main()
{
int n,x,y,z,a,b,p,i,j,f;
while(scanf("%d",&n)!=EOF)
{
scanf("%d%d%d",&x,&y,&z);
for(i=9;i>0;i--)
{
f=0;
for(j=9;j>=0;j--)
{
if((i*10000+j+x*1000+y*100+z*10)%n==0)
{
p=(i*10000+j+x*1000+y*100+z*10)/n;
f=1;
break;
}
}
if(f==1) break;
}
if(i!=0)
printf("%d %d %d\n",i,j,p);
else
printf("0\n");
}
return 0;
} #include <stdio.h>
//using namespace std;
int main(){
int n,x,y,z;
while(scanf("%d\n%d %d %d",&n,&x,&y,&z)!=EOF){
int i,j;
int max=0,maxi,maxj;
int price;
for(i=1;i<10;i++){
for(j=0;j<10;j++){
price = i*10000+x*1000+y*100+z*10+j;
if((price%n==0) && price>(max*n)){
max = price/n;
maxi = i;
maxj = j;
}
}
}
if(max==0)
printf("0\n");
else
printf("%d %d %d\n",maxi,maxj,max);
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int n,x,y,z;
while(cin>>n)
{
cin>>x>>y>>z;
int tmp1,tmp2,max = 0;
int cnt = x*1000+y*100+z*10;
int sta = 0,end = 0;
bool flag = false;
for(int i=1;i<=9;i++)
for(int j=0;j<=9;j++)
{
tmp1 = (i*10000+cnt+j)%n;
tmp2 = (i*10000+cnt+j)/n;
if(tmp1==0&&tmp2 > max)
{
max = tmp2;
sta = i;
end = j;
}
}
if(sta==0&&end==0) cout<<0<<endl;
else cout<<sta<<" "<<end<<" "<<max<<endl;
}
return 0;
} #include<stdio.h>
int main()
{
int n,x,y,z,i,j;
int wan=0,ge=0,danjia;
scanf("%d",&n);
scanf("%d%d%d",&x,&y,&z);
for(i=1;i<=9;i++)//万位
for(j=0;j<=9;j++)//个位
if((i*10000+x*1000+y*100+z*10+j)%n==0)//能够整除
wan=i;ge=j;danjia=(i*10000+x*1000+y*100+z*10+j)/n;//由于要最高单价,所以正常向上循环就是最大单价不需处理
if(wan==0)//表示未能被n整除或者不是五位数
printf("0");
else
printf("%d %d %d",wan,ge,danjia);
} #include <iostream>
#include <algorithm>
using namespace std;
void judge(int n,int m1,int m2,int m3){
for(int first=9;first>0;first--){
for(int last=9;last>=0;last--){
int num = first*10000+m1*1000+m2*100+m3*10+last;
if(num % n == 0){
cout<<first<<" "<<last<<" "<<num/n<<endl;
return;
}
}
}
cout<<0;
return;
}
int main(){
int n,m1,m2,m3;
while(cin>>n>>m1>>m2>>m3){
judge(n,m1,m2,m3);
}
return 0;
} #include<stdio.h>
int main(){
int n;
while(scanf("%d",&n)!=EOF){
int x,y,z;
int a,b;
scanf("%d%d%d",&x,&y,&z);
int price=0;
int mid=x*1000+y*100+z*10;
for(int i=1;i<10;i++){
for(int j=0;j<10;j++){
int num=i*10000+mid+j;
if(num%n==0&&price<num/n){
price=num/n;
a=i;b=j;
}
}
}
if(price==0)printf("0\n");
else printf("%d %d %d\n",a,b,price);
}
return 0;
} #include <iostream>
#include <sstream>
#include <stack>
#include <string>
using namespace std;
int main() {
int n, x, y, z;
while (cin >> n >> x >> y >> z) {
for (int i = 9; i >= 1; i--) {
for (int j = 9; j >= 0; j--) { //从最贵的开始找
int price = 10000 * i + 1000 * x + 100 * y + 10 * z + j;
if (price % n == 0) {
cout << i << " " << j << " " << price / n << endl;
goto find; //找到
}
}
}
cout << 0 << endl; //未找到
find:
;
}
return 0;
}