文章目录
1.平方和
问题描述:
小明对数位中含有 2、0、1、9 的数字很感兴趣,在 1 到 40 中这样的数包括 1、2、9、10 至 32、39 和 40,共 28 个,他们的和是 574,平方和是 14362。注意,平方和是指将每个数分别平方后求和。
请问,在 1 到 2019 中,所有这样的数的平方和是多少?
答案:624
可以直接用数学思维解决:首先是1-99总共有20个2,而100-199,300-399…同样如此,而200-299则不是,他总共有120个2,所以一千以内总共有209+120,0-1999则共有(209+120)*2 = 600个2,在计算2000-2020中一共有21 + 3 = 24个2,所以共有624个2,同样也可以用代码写出,如下:
解析代码:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
int cnt = 0;
void remainder(int x)
{
while(x)
{
int num = x % 10;
if(num == 2) cnt++;
x /= 10;
}
}
int main()
{
for(int i = 1; i <= 2020; i++)
{
remainder(i);
}
printf("%d\n", cnt);
return 0;
}
2.数列求值
问题描述:
给定数列 1, 1, 1, 3, 5, 9, 17, …,从第 4 项开始,每项都是前 3 项的和。求第 20190324 项的最后 4 位数字。
答案:4659
解析代码:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
int a[20190330];
int main()
{
a[1] = 1;
a[2] = 1;
a[3] = 1;
for(int i = 4; i <= 20190324; i++)
{
a[i] = a[i - 1] + a[i - 2] + a[i - 3];
a[i] %= 10000;
}
printf("%d\n", a[20190324]);
return 0;
}
3.最大降雨量
问题描述:
由于沙之国长年干旱,法师小明准备施展自己的一个神秘法术来求雨。
这个法术需要用到他手中的 49 张法术符,上面分别写着 1 至 49 这 49 个数字。法术一共持续 7 周,每天小明都要使用一张法术符,法术符不能重复使用。
每周,小明施展法术产生的能量为这周 7 张法术符上数字的中位数。法术施展完 7 周后,求雨将获得成功,降雨量为 7 周能量的中位数。
由于干旱太久,小明希望这次求雨的降雨量尽可能大,请问最大值是多少?
答案:34
49 48 47 46 3 2 1
45 44 43 42 6 5 4
…
37 36 35 34 12 11 10 以此类推
…
25 24 23 22 21 20 19
最后所得中位数为34
1.平方和
问题描述:
小明对数位中含有 2、0、1、9 的数字很感兴趣,在 1 到 40 中这样的数包括 1、2、9、10 至 32、39 和 40,共 28 个,他们的和是 574,平方和是 14362。注意,平方和是指将每个数分别平方后求和。
请问,在 1 到 2019 中,所有这样的数的平方和是多少?
答案:624
可以直接用数学思维解决:首先是1-99总共有20个2,而100-199,300-399…同样如此,而200-299则不是,他总共有120个2,所以一千以内总共有209+120,0-1999则共有(209+120)*2 = 600个2,在计算2000-2020中一共有21 + 3 = 24个2,所以共有624个2,同样也可以用代码写出,如下:
解析代码:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
int cnt = 0;
void remainder(int x)
{
while(x)
{
int num = x % 10;
if(num == 2) cnt++;
x /= 10;
}
}
int main()
{
for(int i = 1; i <= 2020; i++)
{
remainder(i);
}
printf("%d\n", cnt);
return 0;
}
1.平方和
问题描述:
小明对数位中含有 2、0、1、9 的数字很感兴趣,在 1 到 40 中这样的数包括 1、2、9、10 至 32、39 和 40,共 28 个,他们的和是 574,平方和是 14362。注意,平方和是指将每个数分别平方后求和。
请问,在 1 到 2019 中,所有这样的数的平方和是多少?
答案:624
可以直接用数学思维解决:首先是1-99总共有20个2,而100-199,300-399…同样如此,而200-299则不是,他总共有120个2,所以一千以内总共有209+120,0-1999则共有(209+120)*2 = 600个2,在计算2000-2020中一共有21 + 3 = 24个2,所以共有624个2,同样也可以用代码写出,如下:
解析代码:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
int cnt = 0;
void remainder(int x)
{
while(x)
{
int num = x % 10;
if(num == 2) cnt++;
x /= 10;
}
}
int main()
{
for(int i = 1; i <= 2020; i++)
{
remainder(i);
}
printf("%d\n", cnt);
return 0;
}
1.平方和
问题描述:
小明对数位中含有 2、0、1、9 的数字很感兴趣,在 1 到 40 中这样的数包括 1、2、9、10 至 32、39 和 40,共 28 个,他们的和是 574,平方和是 14362。注意,平方和是指将每个数分别平方后求和。
请问,在 1 到 2019 中,所有这样的数的平方和是多少?
答案:624
可以直接用数学思维解决:首先是1-99总共有20个2,而100-199,300-399…同样如此,而200-299则不是,他总共有120个2,所以一千以内总共有209+120,0-1999则共有(209+120)*2 = 600个2,在计算2000-2020中一共有21 + 3 = 24个2,所以共有624个2,同样也可以用代码写出,如下:
解析代码:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
int cnt = 0;
void remainder(int x)
{
while(x)
{
int num = x % 10;
if(num == 2) cnt++;
x /= 10;
}
}
int main()
{
for(int i = 1; i <= 2020; i++)
{
remainder(i);
}
printf("%d\n", cnt);
return 0;
}
1.平方和
问题描述:
小明对数位中含有 2、0、1、9 的数字很感兴趣,在 1 到 40 中这样的数包括 1、2、9、10 至 32、39 和 40,共 28 个,他们的和是 574,平方和是 14362。注意,平方和是指将每个数分别平方后求和。
请问,在 1 到 2019 中,所有这样的数的平方和是多少?
答案:624
可以直接用数学思维解决:首先是1-99总共有20个2,而100-199,300-399…同样如此,而200-299则不是,他总共有120个2,所以一千以内总共有209+120,0-1999则共有(209+120)*2 = 600个2,在计算2000-2020中一共有21 + 3 = 24个2,所以共有624个2,同样也可以用代码写出,如下:
解析代码:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
int cnt = 0;
void remainder(int x)
{
while(x)
{
int num = x % 10;
if(num == 2) cnt++;
x /= 10;
}
}
int main()
{
for(int i = 1; i <= 2020; i++)
{
remainder(i);
}
printf("%d\n", cnt);
return 0;
}
1.平方和
问题描述:
小明对数位中含有 2、0、1、9 的数字很感兴趣,在 1 到 40 中这样的数包括 1、2、9、10 至 32、39 和 40,共 28 个,他们的和是 574,平方和是 14362。注意,平方和是指将每个数分别平方后求和。
请问,在 1 到 2019 中,所有这样的数的平方和是多少?
答案:624
可以直接用数学思维解决:首先是1-99总共有20个2,而100-199,300-399…同样如此,而200-299则不是,他总共有120个2,所以一千以内总共有209+120,0-1999则共有(209+120)*2 = 600个2,在计算2000-2020中一共有21 + 3 = 24个2,所以共有624个2,同样也可以用代码写出,如下:
解析代码:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
int cnt = 0;
void remainder(int x)
{
while(x)
{
int num = x % 10;
if(num == 2) cnt++;
x /= 10;
}
}
int main()
{
for(int i = 1; i <= 2020; i++)
{
remainder(i);
}
printf("%d\n", cnt);
return 0;
}
1.平方和
问题描述:
小明对数位中含有 2、0、1、9 的数字很感兴趣,在 1 到 40 中这样的数包括 1、2、9、10 至 32、39 和 40,共 28 个,他们的和是 574,平方和是 14362。注意,平方和是指将每个数分别平方后求和。
请问,在 1 到 2019 中,所有这样的数的平方和是多少?
答案:624
可以直接用数学思维解决:首先是1-99总共有20个2,而100-199,300-399…同样如此,而200-299则不是,他总共有120个2,所以一千以内总共有209+120,0-1999则共有(209+120)*2 = 600个2,在计算2000-2020中一共有21 + 3 = 24个2,所以共有624个2,同样也可以用代码写出,如下:
解析代码:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
int cnt = 0;
void remainder(int x)
{
while(x)
{
int num = x % 10;
if(num == 2) cnt++;
x /= 10;
}
}
int main()
{
for(int i = 1; i <= 2020; i++)
{
remainder(i);
}
printf("%d\n", cnt);
return 0;
}
1.平方和
问题描述:
小明对数位中含有 2、0、1、9 的数字很感兴趣,在 1 到 40 中这样的数包括 1、2、9、10 至 32、39 和 40,共 28 个,他们的和是 574,平方和是 14362。注意,平方和是指将每个数分别平方后求和。
请问,在 1 到 2019 中,所有这样的数的平方和是多少?
答案:624
可以直接用数学思维解决:首先是1-99总共有20个2,而100-199,300-399…同样如此,而200-299则不是,他总共有120个2,所以一千以内总共有209+120,0-1999则共有(209+120)*2 = 600个2,在计算2000-2020中一共有21 + 3 = 24个2,所以共有624个2,同样也可以用代码写出,如下:
解析代码:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
int cnt = 0;
void remainder(int x)
{
while(x)
{
int num = x % 10;
if(num == 2) cnt++;
x /= 10;
}
}
int main()
{
for(int i = 1; i <= 2020; i++)
{
remainder(i);
}
printf("%d\n", cnt);
return 0;
}