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
    **********************************************************************/
  • 相关阅读:
    Java中只有按值传递,没有按引用传递!(两种参数情况下都是值传递)
    最简单的struts实例介绍
    Spring中bean的五个作用域简介(转载)
    Spring配置文件
    轻松搞定面试中的二叉树题目 (转)
    二叉树
    稳定排序与非稳定排序判别方法
    Yii的缓存机制之动态缓存
    Yii的缓存机制之数据缓存
    Yii的缓存机制之页面缓存
  • 原文地址:https://www.cnblogs.com/jkzr/p/10030678.html
Copyright © 2011-2022 走看看