zoukankan      html  css  js  c++  java
  • Codeforces 260 B. Fedya and Maths

    题目链接:http://codeforces.com/contest/456/problem/B

    解题报告:输入一个n,让你判断(1n + 2n + 3n + 4nmod 5的结果是多少?注意n的范围很大很大 n (0 ≤ n ≤ 10105).

    只要判断是否能被整除4就可以了,如果n能被4整除,则结果是4,如果不能,则结果是0

    但n很长,不能直接mod,但只要判断最低的两位能不能被4整除就可以了,如果n只有一位就判断最低的一位。

     1 #include<cstdio>
     2 #include<cstring>
     3 #include<iostream>
     4 #include<algorithm>
     5 #include<cmath>
     6 #include<deque>
     7 #include<queue>
     8 #include<set>
     9 #include<map>
    10 using namespace std;
    11 #define maxn 100005
    12 char str[maxn];
    13 int main()
    14 {
    15     while(scanf("%s",str)!=EOF)
    16     {
    17         int temp,len = strlen(str);
    18         if(len <= 1)
    19         temp = str[0] - '0';
    20         else temp = 10 * (str[len - 2] - '0') + (str[len - 1] - '0');
    21         printf(temp % 4? "0
    ":"4
    ");
    22     }
    23     return 0;
    24 }
    View Code
  • 相关阅读:
    time fly
    小论文初稿终于完成
    leetcode之Length of Last Word
    static关键字
    参数传递
    this关键字
    面向对象有三大特征
    空指针异常
    变量按数据类型分为
    构造方法
  • 原文地址:https://www.cnblogs.com/xiaxiaosheng/p/3903459.html
Copyright © 2011-2022 走看看