zoukankan      html  css  js  c++  java
  • 2991:2011

    2991:2011

    总时间限制:
    1000ms
    内存限制:
    65536kB
    描述
    已知长度最大为200位的正整数n,请求出2011^n的后四位。
    输入
    第一行为一个正整数k,代表有k组数据,k<=200接下来的k行,

    每行都有一个正整数n,n的位数<=200
    输出
    每一个n的结果为一个整数占一行,若不足4位,去除高位多余的0
    样例输入
    3
    5
    28
    792
    样例输出
    1051
    81
    5521
     1 #include <math.h>
     2 #include <stdio.h>
     3 #include <stdlib.h>
     4 #include <string.h>
     5 #include <time.h>
     6 #include <queue>
     7 #include <vector>
     8 #include <algorithm>
     9 #include <functional>
    10 #include <iostream>
    11 using namespace std;
    12 int n=500,o,i,p;
    13 int cas,a[505]={0,2011},length,x;
    14 char c[205];
    15 int main()
    16 {
    17 for (i=2;i<=n;i++)
    18 {
    19 a[i]=(a[i-1]*2011)%10000;
    20 }
    21 scanf ("%d",&cas);
    22 for (i=1;i<=cas;i++)
    23 {
    24 memset (c,0,sizeof(c));
    25 x=0;
    26 scanf ("%s",c);
    27 length=strlen(c);
    28 if (length>=3)
    29 {
    30 for (o=length-3;o<=length-1;o++)
    31 x=x*10+c[o]-'0';
    32 }
    33 else
    34 x=(int)atof(c);
    35 if (x<=500)
    36 printf ("%d
    ",a[x]);
    37 else
    38 printf ("%d
    ",a[x-500]);
    39 }
    40 return 0;
    41 }
  • 相关阅读:
    5.11号团队冲刺(十)
    5.10号团队冲刺(九)
    python day04
    python day03
    python day02
    python day01
    模板语法标签继承关系
    DNS解析详情
    和域名相关的知识
    Webpack 4.X webpack.config.js 文件配置(一)
  • 原文地址:https://www.cnblogs.com/zwfymqz/p/6613406.html
Copyright © 2011-2022 走看看