ZCMU 1294: OD

Description

In cryptography, encryption is the process of encoding messages (or information) in such a way that third parties cannot read it, but only authorized parties can. Encryption doesn't prevent hacking but it prevents the hacker from reading the data that is encrypted. In an encryption scheme, the message or information (referred to as plaintext) is encrypted using an encryption algorithm, turning it into an unreadable ciphertext (ibid.). This is usually done with the use of an encryption key, which specifies how the message is to be encoded. Any adversary that can see the ciphertext should not be able to determine anything about the original message. An authorized party, however, is able to decode the ciphertext using a decryption algorithm, that usually requires a secret decryption key, that adversaries do not have access to. For technical reasons, an encryption scheme usually needs a key-generation algorithm to randomly produce keys.

There are so many ways to encrypt a message. In general, there are two kinds of method: Symmetric key encryption and Public key encryption. In Symmetric-key schemes, the encryption and decryption keys are the same. Thus communicating parties must agree on a secret key before they wish to communicate. But In public-key encryption schemes, the encryption key is published for anyone to use and encrypt messages. However, only the receiving party has access to the decryption key and is capable of reading the encrypted messages. Public-key encryption is a relatively recent invention: historically, all encryption schemes have been symmetric-key (also called private-key) schemes. Likewise, there are many algorithms used in encryption efficiently, such as DES(Data Encryption Standard), 3DES, RC2&RC4, IDEA and so forth. What’s more, you can also define your own rules to encrypt messages. For example, we can define a method named OE which first makes every digit of the number add 9 then mod 10. Then separate the digits in odd positions and the digits in even positions from the new number in their original order, then connect the two parts with the set of digits in odd positions first.

One of the earliest public key encryption applications was called Pretty Good Privacy (PGP). It was written in 1991 by Phil Zimmermann and was purchased by Symantec in 2010.

Encryption is also used to protect data in transit, for example data being transferred via networks (e.g. the Internet, e-commerce), mobile telephones, wireless microphones, wireless intercom systems, Bluetooth devices and bank automatic teller machines. There have been numerous reports of data in transit being intercepted in recent years. Encrypting data in transit also helps to secure it as it is often difficult to physically secure all access to networks.

Digital signature and encryption must be applied at message creation time (i.e. on the same device it has been composed) to avoid tampering. Otherwise any node between the sender and the encryption agent could potentially tamper it. It should be noted that encrypting at the time of creation only adds security if the encryption device itself has not been tampered with.

With the information on encryption above, you also want to encryption some passwords with some ingenious methods and efficient algorithms. To make the problem more easier, your task is to encrypt a number with your own method------OE. Good luck, ACMer!

Input

First line contains a positive integer T(T<=10000). Then T cases follow. Each case contains one line with a positive number N(N<100000000), which stands for the password.

Output

One line for each case, output the password after encrypted in OE method.

Sample Input

2

1257

5321041

Sample Output

0416

4190203

【分析】

有用的就这一段,For example, we can define a method named OE which first makes every digit of the number add 9 then mod 10. Then separate the digits in odd positions and the digits in even positions from the new number in their original order, then connect the two parts with the set of digits in odd positions first.翻译过来就是把每个数字加9余10.然后将偶数位置的数字按原来顺序全部提出来然后接在剩下的奇数位置的后面

#include<stdio.h>
int main()
{
    int t,x,k;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&k);
        int dig=0;
        x=k;
        while(x>0)
        {//得到位数
            x/=10;
            dig++;
        }
        int a[10],b[10];
        for(int i=dig;i>0;i--)
        {
            a[i]=(k%10+9)%10;k=k/10;
        }//得到每位加密后的数字存在数组a中

        int c=1;int t=(dig+1)/2+1;
        for(int j=1;j<=dig;j++)
        {
            if(j%2==1){b[c]=a[j];c++;}
            else {b[t]=a[j];t++;}
        }//按奇偶要求转存到数组b

        for(int z=1;z<=dig;z++)
            printf("%d",b[z]);
        //输出
     printf("\n");
    }
    return 0;
}

下面这个没过,不知道错哪

#include<bits/stdc++.h>
int main()
{
    char a[10],t;
    scanf("%d",&t);
    while(t--)
        {
        scanf("%s",a);
        int len=strlen(a);
        for(int i=0;i<len;i++)
        {
            if(i%2==0)printf("%d",(a[i]-'0'+9)%10);
        }
        for(int j=0;j<len;j++)
        {
            if(j%2==1)printf("%d",(a[j]-'0'+9)%10);
        }
        printf("\n");
    }
    return 0;
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: zcmu 1093 简单计算器是一道编程题目,要求实现一个简单的计算器,能够进行加、减、乘、除四种基本运算。该题目主要考察编程基础能力和算法思维能力,需要熟练掌握基本的运算符和控制语句,能够设计合理的算法实现计算器功能。 ### 回答2: zcmu 1093 简单计算器是一种基于计算机技术的工具,用于进行基本算术运算,如加减乘除等。它能够简化我们在日常生活中的计算工作,提高计算效率,减少出错率。 使用zcmu 1093 简单计算器非常简单,只需输入需要计算的数字和符号,就能够得到计算结果。它可以进行多个数字之间的复杂运算,同时还支持小数、百分数、平方根等复杂运算。另外,zcmu 1093 简单计算器还可以存储中间计算结果,方便我们进行多步计算或调整计算过程。 除了日常的计算工作,zcmu 1093 简单计算器还可用于科学计算、工程设计等领域。许多专业软件都是基于简单计算器原理设计的,它们具有更高的计算精度和更复杂的运算能力,能够支持更高级别的科学计算和技术分析。 总之,zcmu 1093 简单计算器在日常生活中有着广泛的应用,它使我们的计算工作变得更加高效、准确。并且,随着科技的不断发展,这种计算工具也在不断地更新和改进,为我们的计算工作提供更加便捷、多样化的选择。 ### 回答3: ZCMU 1093 简单计算器是一道基础的算法题目,需要实现一个简单的计算器程序,支持加、减、乘、除四种基本运算,可以对两个整数进行运算并输出结果。 要实现这道题目,首先需要根据输入的运算符来判断应该进行的运算类型,并根据运算符的不同,执行不同的计算操作。同时,应注意除数不能为零的情况,避免程序出现异常。 在编写程序的过程中,可以使用 switch case 语句来判断不同的运算类型,并执行相应的计算操作。同时,为了能有效地判断输入的运算符,可以使用输入字符串的方式进行处理,提取出运算符进行比较。 此外,在程序中还需要进行合法性判断,确保输入的数字均为整数且在合理的范围内,以避免程序运行出现异常情况。同时,还需要考虑输入格式的问题,应确保输入的数字和运算符符合题目要求。 综上所述,ZCMU 1093 简单计算器是一道基础的算法题目,需要实现一个简单的计算器程序,支持加、减、乘、除四种基本运算,注意程序的合法性判断和输入格式的处理,能够熟练地运用 switch case 等语句完成程序的编写。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值