UVA11547 Automatic Answer【水题】

Last month Alice nonchalantly entered her name in a draw for a Tapmaster 4000. Upon checking her mail today, she found a letter that read:
    “Congratulations, Alice! You have won a Tapmaster 4000. To claim your prize, you must answer the following skill testing question.”
    Alice’s initial feelings of surprised joy turned quickly to those of dismay. Her lifetime record for skill testing questions is an abysmal 3 right and 42 wrong.
    Mad Skills, the leading skill testing question development company, was hired to provide skill testing questions for this particular Tapmaster 4000 draw. They decided to create a different skill testing question to each winner so that the winners could not collaborate to answer the question.
    Can you help Alice win the Tapmaster 4000 by solving the skill testing question?
Input
The input begins with t (1 ≤ t ≤ 100), the number of test cases. Each test case contains an integer n (−1000 ≤ n ≤ 1000) on a line by itself. This n should be substituted into the skill testing question below.
Output
For each test case, output the answer to the following skill testing question on a line by itself:
    “Multiply n by 567, then divide the result by 9, then add 7492, then multiply by 235, then divide by 47, then subtract 498. What is the digit in the tens column?”
Sample Input
2
637
-120
Sample Output
1
3

问题链接UVA11547 Automatic Answer
问题简述:(略)
问题分析
    输入整数n(-1000<=n<=1000),乘以567,然后除以9,然后加7492,结果再乘以235,然后再除以47,最后再减去498,求其十位的数字是多少?
    这里给出2种程序,各有技巧不同,细节可看代码。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA11547 Automatic Answer */

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int t, n;
    scanf("%d",&t);
    while(t--) {
        scanf("%d",&n);
        n = (((((n * 567) / 9) + 7492) * 235) / 47) - 498;
        if(n < 0) n = -n;
        printf("%d\n", n / 10 % 10);
    }

    return 0;
}

AC的C++语言程序如下:

/* UVA11547 Automatic Answer */

#include <iostream>

using namespace std;

char buff[24];

int main()
{
    int t, n, len;
    scanf("%d",&t);
    while(t--) {
        scanf("%d",&n);
        n = (((((n * 567) / 9) + 7492) * 235) / 47) - 498;
        len = sprintf(buff, "%d", n);
        putchar(buff[len - 2]);
        putchar('\n');
    }

    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值