• 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
    **********************************************************************/
  • 相关阅读:
    linux API 获得文件属性
    Linux 服务端设计
    Linux C++ 使用LuaBind嵌入lua脚本
    Linux 编译安装Boost (转)
    Navicat for My SQL 查看中文乱码问题
    fastbuild联编ue4 shader的使用
    fastbuild进行ue4 shader连编
    maya 插件学习之pythonCharm和Qt环境搭建
    ue4 头发渲染
    ue4 新渲染管线整理
  • 原文地址:https://www.cnblogs.com/jkzr/p/10030678.html
Copyright © 2020-2023  润新知