avator密码



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

HINT

#include<iostream>
#include<cstring>
using namespace std;
char *reverse(char *s) 

    char temp; 
    char *p = s;    //p指向s的头部 
    char *q = s;    //q指向s的尾部 
    while(*q) 
        ++q; 
    q--; 
 
    //交换移动指针,直到p和q交叉 
    while(q > p) 
    { 
        temp = *p; 
        *p++ = *q; 
        *q-- = temp; 
    } 
    return s; 

 
/*
23. * 功能:整数转换为字符串
24. * char s[] 的作用是存储整数的每一位
*/ 
char *my_itoa(int n) 

    int i = 0,isNegative = 0; 
    static char s[100];      //必须为static变量,或者是全局变量 
    if((isNegative = n) < 0) //如果是负数,先转为正数 
    { 
        n = -n; 
    } 
    do      //从各位开始变为字符,直到最高位,最后应该反转 
    { 
        s[i++] = n%10 + '0'; 
        n = n/10; 
   }while(n > 0); 
 
    if(isNegative < 0)   //如果是负数,补上负号 
    { 
        s[i++] = '-'; 
    } 
   s[i] = '\0';    //最后加上字符串结束符 
    return reverse(s);   
}
main()
{
int n;
scanf("%d",&n);
while(n--){
 int a,b;
 scanf("%d%d",&a,&b);
 int c;
 c=a*b;
 char d[100];
  memset(d ,'a', sizeof(d));
  
   // char l=my_itoa(c);
 
 //int tail;
 string g=my_itoa(c);
 int nn=g.length()-1;
 cout<<g[nn-3]<<g[nn-2]<<g[nn-1]<<g[nn]<<endl;
 //printf("%s",my_itoa(c));
/* for(int i=0;i<100;i++){
  if(d[i]=='a') {tail=i;break;}
 }
 
 printf("%c%c%c%c",d[tail-5],d[tail-4],d[tail-3],d[tail-2]);*/
}

return 0;
}

代码比较乱,中间有些注释的部分是我在做题过程中实验所用,无视就行(实在没心情挨个删除了),这破题花了我将近两个小时,开始想用课设中使用的两个大数相乘的原理,结果不知哪里出了问题总是算不对,无奈选择将int型转为char类型这一思路,本来c语言有一个非标准库中包含这个函数,即itoa函数,可是oj系统的c/c++都没有这个库,无奈又从网上找了这个函数的算法,虽然我并没有看,直接复制过来。。这才终于解决了这一问题,啊啊啊啊啊  我的时间都让这个破题浪费了!!!


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值