SSL-ZYC 2402 世界语

题目大意:
这里写图片描述


思路:
这道题找到每个数之间的规律后,可以直接模拟。


代码:

#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

int n;
string a[11];

int main()
{
    cin>>n;
    a[1]="unu";
    a[2]="du";
    a[3]="tri";
    a[4]="kvar";
    a[5]="kvin";
    a[6]="ses";
    a[7]="sep";
    a[8]="ok";
    a[9]="nau";
    a[10]="dek";  //记录1~10的单词
    if (n<=10)   //开始分治,小于等于10可以直接输出
    {
        cout<<a[n]<<endl;
        return 0;
    }
    if (n<=19)  //10~19的部分
    {
        cout<<a[10]<<" "<<a[n%10]<<endl;
        return 0;
    }
    if (n%10==0)  //整十数的部分
    {
        cout<<a[n/10]<<a[10]<<endl;
        return 0;
    }
    cout<<a[n/10]<<a[10]<<" "<<a[n%10]<<endl;  //剩余
    return 0;
}

猜你喜欢

转载自blog.csdn.net/ssl_zyc/article/details/80028503
今日推荐