九度OJ 1036 Old Bill (模拟)

题目1036:Old Bill

时间限制:1 秒

内存限制:32 兆

特殊判题:否

提交:2302

解决:1211

题目描述:

Among grandfather‘s papers a bill was found.

72 turkeys $_679_

The first and the last digits of the number that obviously represented the total price of those turkeys are replaced here by blanks (denoted _), for they are faded and are illegible. What are the two faded digits and what was the price of one turkey?

We want to write a program that solves a general version of the above problem.

N turkeys $_XYZ_

The total number of turkeys, N, is between 1 and 99, including both. The total price originally consisted of five digits, but we can see only the three digits in the middle. We assume that the first digit is nonzero, that the price of one turkeys is an
integer number of dollars, and that all the

turkeys cost the same price.

Given N, X, Y, and Z, write a program that guesses the two faded digits and the original price. In case that there is more than one candidate for the original price, the output should be the most expensive one. That is, the program is to report the two
faded digits and the maximum price per turkey for the turkeys.

输入:

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 N;
int X;
int Y;
int Z;
int A;
int B;
int ans;
int check(int num){
    int sum=N*num;
    if((sum/10)%10==Z&&(sum/100)%10==Y&&(sum/1000)%10==X)
    {
        A=(sum/10000)%10;
        B=(sum%10);
        ans=num;
        return 1;
    }
    return 0;
}
void output()
{
    printf("%d %d %d\n",A,B,ans);
}
int main(int argc, char *argv[])
{
    freopen("1036.in","r",stdin);
    while(~scanf("%d",&N))
    {
        scanf("%d %d %d",&X,&Y,&Z);
        int M=99999/N;
        for(int i=M;;--i)
        {
            if(check(i)){
                output();
                break;
            }
            if(i<=0){
                printf("0\n");
                break;
            }
        }
    }
    return 0;
}
时间: 2024-08-04 01:23:12

九度OJ 1036 Old Bill (模拟)的相关文章

九度OJ 打印日期 (模拟)

题目1186:打印日期 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4284 解决:1483 题目描写叙述: 给出年分m和一年中的第n天,算出第n天是几月几号. 输入: 输入包含两个整数y(1<=y<=3000),n(1<=n<=366). 输出: 可能有多组測试数据,对于每组数据, 按 yyyy-mm-dd的格式将输入中相应的日期打印出来. 例子输入: 2000 3 2000 31 2000 40 2000 60 2000 61 2001 60 例子输出: 2000

九度OJ 1014 排名 (模拟)

这题做了后,不敢再用C++输入输出了,艾玛...调C++的runtime error,调了一上午,原来才发现是那个std::ios::sync_with_stdio(false)有问题!!以后再慢慢尝试这个语句把吧 题目1014:排名 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:7462 解决:2213 题目描述:     今天的上机考试虽然有实时的Ranklist,但上面的排名只是根据完成的题数排序,没有考虑每题的分值,所以并不是最后的排名.给定录取分数线,请你写程序找出最后通过

九度OJ 1179 阶乘(模拟)

题目1179:阶乘 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4526 解决:1315 题目描写叙述: 输入n, 求y1=1!+3!+...m!(m是小于等于n的最大奇数) y2=2!+4!+...p!(p是小于等于n的最大偶数). 输入: 每组输入包含1个整数:n 输出: 可能有多组測试数据,对于每组数据, 输出题目要求的y1和y2 例子输入: 4 例子输出: 7 26 #include<stdio.h> unsigned long long n; unsigned long

[ACM] 九度OJ 1553 时钟

时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:1733 解决:656 题目描述: 如图,给定任意时刻,求时针和分针的夹角(劣弧所对应的角). 输入: 输入包含多组测试数据,每组测试数据由一个按hh:mm表示的时刻组成. 输出: 对于每组测试数据,输出一个浮点数,代表时针和分针的夹角(劣弧对应的角),用角度表示,结果保留两位小数. 样例输入: 03:00 14:45 样例输出: 90.00 172.50 来源: 2014年王道论坛计算机考研机试全真模拟考试 解题思路: 求时针和分针的

[九度OJ]货币问题,解题报告

题目 题目描述: 已知有面值为1元,2元,5元,10元,20元,50元,100元的货币若干(可认为无穷多),需支付价格为x的物品,并需要恰好支付,即没有找零产生. 求,至少需要几张货币才能完成支付. 如,若支付价格为12元的物品,最少需要一张10元和一张2元,即两张货币就可完成支付. 输入: 输入包含多组测试数据,每组仅包含一个整数p(1<=p<=100000000),为需支付的物品价格. 输出: 对于每组输入数据,输出仅一个整数,代表最少需要的货币张数. 样例输入: 10 11 13 样例输

九度oj 题目1007:奥运排序问题

九度oj 题目1007:奥运排序问题   恢复 题目描述: 按要求,给国家进行排名. 输入:                        有多组数据. 第一行给出国家数N,要求排名的国家数M,国家号从0到N-1. 第二行开始的N行给定国家或地区的奥运金牌数,奖牌数,人口数(百万). 接下来一行给出M个国家号. 输出:                        排序有4种方式: 金牌总数 奖牌总数 金牌人口比例 奖牌人口比例 对每个国家给出最佳排名排名方式 和 最终排名 格式为: 排名:排名

[ACM] 九度OJ 合唱队形 (最长递增子序列改版)

题目1131:合唱队形 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:1680 解决:520 题目描述: N位同学站成一排,音乐老师要请其中的(N-K)位同学出列,使得剩下的K位同学不交换位置就能排成合唱队形. 合唱队形是指这样的一种队形:设K位同学从左到右依次编号为1, 2, -, K,他们的身高分别为T1, T2, -, TK, 则他们的身高满足T1 < T2 < - < Ti , Ti > Ti+1 > - > TK (1 <= i <=

九度oj 题目1546:迷宫问题 (概率dp guess消元)

题目链接:点击打开链接 题目描述: 给定一个n*m的迷宫,如 S.. ..# E.E 其中,S代表开始位置,#代表不可行走的墙,E代表出口. 主人公从开始位置出发,每次等概率的随机选择下一个可以行走的位置,直到到达某一个出口为止. 现在他想知道,在这一概率事件中,它从开始位置走到某一个出口的期望步数是多少. 输入: 输入包含多组测试用例,每组测试用例由两个整数n,m(1<=n,m<=15)开始,代表迷宫的大小 接下去n行每行m个字符描述迷宫信息,具体规则如题面所述. 数据保证至少存在一个E和一

九度oj题目1009:二叉搜索树

题目描述: 判断两序列是否为同一二叉搜索树序列 输入:                        开始一个数n,(1<=n<=20) 表示有n个需要判断,n= 0 的时候输入结束. 接下去一行是一个序列,序列长度小于10,包含(0~9)的数字,没有重复数字,根据这个序列可以构造出一颗二叉搜索树. 接下去的n行有n个序列,每个序列格式跟第一个序列一样,请判断这两个序列是否能组成同一颗二叉搜索树. 输出:                        如果序列相同则输出YES,否则输出NO 样