欧拉计划
来源:互联网 发布:淘宝运营助理工作职责 编辑:程序博客网 时间:2024/04/27 18:54
题目1:
经典代码
#include <iostream>
int sum,x = 1000;
int main()
{
while (x--)sum+=x*!((x%3)&&(x%5));
std::cout<< sum;
}
算法比较优化的
1 #include<iostream> 2 #include<stdlib.h> 3 #include<stdio.h> 4 using namespace std; 5 int main(){ 6 // freopen("/home/qiuweiwen/code/in.txt", "r", stdin); 7 int a; 8 scanf("%d", &a); 9 a--; 10 int cnt_3 = a / 3; 11 int cnt_5 = a / 5; 12 int cnt_15 = a / 15; 13 int all_3 = 3 * (1 + cnt_3) * cnt_3 / 2; 14 int all_5 = 5 * (1 + cnt_5) * cnt_5 / 2; 15 int all_15 = 15 * (1 + cnt_15) * cnt_15 / 2; 16 int ans = all_3 + all_5 - all_15; 17 printf("%d\n", ans); 18 return 0; 19 }
题目2:
经典代码
#include <iostream>#include <algorithm>using namespace std;int main(void){int s = 0;for (int i = 1, j = 2; j < 1000000; j += i, i = j-i)if (j % 2 == 0)s += j;cout << s << endl;return 0;}
题目八:
在VC++中,如果太长了换行是可以这样的:在最后打个\就可以了
#include <stdio.h>int main(){ int i; int result = 1; int temp;char input[1001] = "73167176531330624919225119674426574742355349194934\96983520312774506326239578318016984801869478851843\85861560789112949495459501737958331952853208805511\12540698747158523863050715693290963295227443043557\66896648950445244523161731856403098711121722383113\62229893423380308135336276614282806444486645238749\30358907296290491560440772390713810515859307960866\70172427121883998797908792274921901699720888093776\65727333001053367881220235421809751254540594752243\52584907711670556013604839586446706324415722155397\53697817977846174064955149290862569321978468622482\83972241375657056057490261407972968652414535100474\82166370484403199890008895243450658541227588666881\16427171479924442928230863465674813919123162824586\17866458359124566529476545682848912883142607690042\24219022671055626321111109370544217506941658960408\07198403850962455444362981230987879927244284909188\84580156166097919133875499200524063689912560717606\05886116467109405077541002256983155200055935729725\71636269561882670428252483600823257530420752963450\";
for(i = 0; i < 996; i++) { temp = (input[i] - '0') * (input[i+1] - '0') * (input[i+2] - '0') * (input[i+3] - '0') * (input[i+4] - '0'); if(temp > result) { result = temp; }
} printf("result = %d \n",result);
}
- 欧拉计划 100
- 欧拉计划
- 欧拉计划
- 欧拉计划是什么?
- 欧拉计划
- 欧拉计划3
- 欧拉计划
- 欧拉计划23
- 欧拉计划20
- 欧拉计划21
- 欧拉计划22
- 欧拉计划
- 欧拉计划 1
- 欧拉计划 2
- 欧拉计划 3
- 欧拉计划 4
- 欧拉计划 5
- 欧拉计划 6
- Threads and fork(): think twice before mixing them.
- Win8.1 无法安装驱动,驱动安装失败的解决方案
- 3013-11-23 21:50
- “f”: 不是一个函数。不提示返回值为int
- 湖北工业大学 1783 求n!的位数
- 欧拉计划
- Gson解析(List和Map)格式json数据
- RS100项目进展更新
- 设计模式之原型模式
- c++ stl string类的基本用法
- 过采样技术原理介绍
- 链表和数组的区别
- STL中容器适配器(Container Adapters)
- 响应式编程 Reactive programming-- 1. 简介