## Digital Roots

The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and the process is repeated. This is continued as long as necessary to obtain a single digit.

For example, consider the positive integer 24. Adding the 2 and the 4 yields a value of 6. Since 6 is a single digit, 6 is the digital root of 24. Now consider the positive integer 39. Adding the 3 and the 9 yields 12. Since 12 is not a single digit, the process must be repeated. Adding the 1 and the 2 yeilds 3, a single digit and also the digital root of 39.

`Digtial Roots=(sum-1)%9+1`

## 暴力hdu1003(AC不过)

### 本想用最简单最暴力的方法AC的，结果正确但超时，等我想到更好的办法再继续

``````#include <iostream>
using namespace std;

int main()
{
int n;
cin>>n;
int Case=1;
while(n--)
{
int m;
cin>>m;
int arr[m];
int Max=0;
int l=1,r=m;
for(int i=0;i<m;i++)
{
cin>>arr[i];
Max+=arr[i];
}
for(int i=0;i<m;i++)
{
int sum=0;
for(int j=i;j<m;j++)
{
sum += arr[j];
if (sum > Max) {
l = i + 1;
r = j + 1;
Max = sum;
}
}
}
cout<<"Case "<<Case<<":"<<endl;
cout<<Max<<" "<<l<<" "<<r<<endl;
Case++;
}
return 0;
}``````

# 简介

Map是STL的一个关联容器，它提供一对一（其中第一个可以称为关键字，每个关键字只能在map中出现一次，第二个可能称为该关键字的值）的数据 处理能力，由于这个特性，它完成有可能在我们处理一对一数据的时候，在编程上提供快速通道。我理解相当于python中的字典，弥补了c++没有集合数据类型的缺陷

# 使用map

`#include <map>` //注意，STL头文件没有扩展名.h
map对象是模板类，需要关键字和存储对象两个模板参数：
`std:map<string, int> Ballon;`

# hdu1004

Problem Description
Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the >judges' favorite time is guessing the most popular problem. When the contest is over, they will count >the balloons of each color and find the result.
This year, they decide to leave this lovely job to you.
Input
Input contains multiple test cases. Each test case starts with a number N (0 < N <= 1000) -- the >total number of balloons distributed. The next N lines contain one color each. The color of a balloon >is a string of up to 15 lower-case letters.
A test case with N = 0 terminates the input and this test case is not to be processed.
Output
For each case, print the color of balloon for the most popular problem on a single line. It is >guaranteed that there is a unique solution for each test case.
Sample Input
5
green
red
blue
red
red
3
pink
orange
pink
0
Sample Output
red
pink

# AC代码

``````#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
map<string, int> Ballon;
string color, MaxColor;
int n, max;
while(cin>>n&&n){
Ballon.clear();
while(n--){
cin>>color;
Ballon[color]++;
}
map<string, int>::iterator it;
max = 0;
for(it=Ballon.begin(); it!=Ballon.end(); it++){
if(it->second>max){
max = it->second;
MaxColor = it->first;
}
}
cout<<MaxColor<<endl;
}
return 0;``````

# 安装

``````git clone git@github.com:ghosx/qcloud_ddns.git
cd qcloud_ddns
sudo pip3 install -r requirements.txt``````
• 替换`main.py` 中的 `LOGIN_ID``LOGIN_TOKEN` （登录后访问 这里 创建 `API Token` 即可获得前两个参数
• 修改 `config.json` 中的域名主机记录

# 使用

``python3 main.py``
• `LINUX` 下使用 `crontab` 设置定时任务 (`python3``main.py` 脚本路径自行替换)
``````crontab -e
*/10 * * * * python3 main.py    #每 10 分钟更新一次``````
• 日志记录在 `result.log` 文件中