zoukankan      html  css  js  c++  java
  • CSU1018: Avatar

    1018: Avatar

            Time Limit: 1 Sec     Memory Limit: 128 Mb     Submitted: 841     Solved: 557    


    Description

    In the planet Pandora, Jake found an old encryption algorithm. The plaintext, key and ciphertext are all four decimal numbers and all greater than 0. The way to get the ciphertext from the plaintext and the key is very simple: the ciphertext is the last four digits of the product of the plaintext and the key (for example: the plaintext is 2010 and the key is 4024, and then the product is 8088240. So the ciphertext is 8240).

    Note that the plaintext and the key don’t have leading 0, while the ciphertext might have. Now given the plaintext and the key, you are asked to figure out the ciphertext for Jake quickly.

    Input

    The first line is an integer T, which presents the number of test cases. Then there are T lines, each line has two integers, the first integer is the plaintext and the second is the key.

    Output

    For each test case, output the ciphertext.

    Sample Input

    2
    2010 4024
    1234 1111
    

    Sample Output

    8240
    0974

    题意:水题,给两个数求相乘后的结果的后四位,直接乘,然后把数记录到数组中,然后输出即可。
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <algorithm>
    using namespace std;
    const int maxn=10;
    int T;
    int a,b;
    int ans[maxn];
    int main()
    {
        scanf("%d",&T);
        while(T--)
        {
            scanf("%d %d",&a,&b);
            int temp=a*b;
            for(int i=0;i<4;i++)
            {
                ans[i]=temp%10;
                temp/=10;
            }
            for(int i=3;i>=0;i--)
                printf("%d",ans[i]);
            printf("
    ");
        }
        return 0;
    }
    
    /**********************************************************************
        Problem: 1018
        User: therang
        Language: C++
        Result: AC
        Time:0 ms
        Memory:2024 kb
    **********************************************************************/
  • 相关阅读:
    自适应PC端网页制作使用REM
    iis express添加虚拟目录
    VC++2010组件安装失败解决办法
    AXURE 8弄一个轮播图的步骤
    浏览器在DPI缩放时变化问题
    数据结构综合训练1
    数据结构上机5二叉树遍历
    数据结构-约瑟夫环
    数据结构上机4队列-杨辉三角2
    数据结构上机4队列-杨辉三角1
  • 原文地址:https://www.cnblogs.com/jkzr/p/10030678.html
Copyright © 2011-2022 走看看