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
    **********************************************************************/
  • 相关阅读:
    VirtualBox 给虚拟机绑定IP
    【转】 wget 命令用法详解
    [转]python -m SimpleHTTPServer
    longene QQ 安装目录
    查看mininet交换机中的流表
    aircrack-ng 字典破解WPA / WPA2
    Win7 64 安装Visual Studio 2010和SQL Server 2008 R2
    Floodlight 防火墙是如何起作用的
    小米2000万买域名mi.com
    Windows JDK环境变量的配置
  • 原文地址:https://www.cnblogs.com/jkzr/p/10030678.html
Copyright © 2011-2022 走看看