【HDOJ】1163 -> Eddy's digital Roots
来源:互联网 发布:ubuntu 14.04镜像 编辑:程序博客网 时间:2024/06/01 08:10
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1163
心得:
九余数定理:一个数的九余数等于这个数各位数之和的九余数。换而言之,就是一个数mod9一次,就相当于这个数的各位数相加再mod9一次。对于本题而言,最后返回的数字根不要忘记讨论余数为0的情况。
代码:
#include <iostream>using namespace std;int main(){int n,i,x;while(cin>>n,n){x=n;for(i=1;i<n;i++)x=(x*n)%9;if(!x) x=9;cout<<x<<endl;}return 0;}
- 【HDOJ】1163 -> Eddy's digital Roots
- hdoj 1163 Eddy's digital Roots
- hdoj.1163 Eddy's digital Roots 20140813
- hdoj 1163 Eddy's digital Roots
- HDOJ 1163 Eddy's digital Roots
- HDOJ Eddy's digital Roots
- 1163:Eddy's digital Roots
- HDOJ 1163 Eddy's digital Roots [简单数论]
- HDOJ 1163 Eddy's digital Roots [简单数论]
- HDOJ 1163 Eddy's digital Roots(简单数论)
- hdoj-1163-Eddy's digital Roots【九余数定理】
- Eddy's digital Roots
- Eddy's digital Roots
- Eddy's digital Roots
- Eddy's digital Roots
- Eddy's digital Roots
- hdu 1163 Eddy's digital Roots
- 杭电1163 Eddy's digital Roots
- 结构体数组初始化
- c语言字符串函数的实现
- 解决VS2010在程序根目录生成ipch文件夹和.sdf格式文件问题
- Java:在Bean中使用PropertyChangeSupport支持PropertyChangeListeners 2007-08-03 18:1
- Java多线程——5 阻塞型同步、非阻塞型同步和Lock-Free
- 【HDOJ】1163 -> Eddy's digital Roots
- 归纳总结之银行业务调度系统
- HDOJ 1203
- 自己写的螺旋矩阵,面试的真心求收藏
- Linux c 基于socket文件的进程通信—对等模型
- ALIGN size as align
- 最长递增子序列(LIS)
- ubuntu下cmake常见两个错误的解决
- [leetcode刷题系列]Combination Sum