- 浏览: 7128 次
- 性别:
- 来自: 广州
最新评论
文章列表
typedef long long lint;
bool isZs(long num) {
if(num < 2) return false;
for (int i = 2; i <= sqrt(num); i++) {
if ((num % i) == 0)
return false;
}
return true;
}
int main(){
lint res = 0;
for(int i=2; i<2000000; i++){
if(isZs(i)){
res += i;
co ...
int findabc(){
for(int i=1;i<1000;i++){
for(int j=2; j<i; j++){
if(1000*i+1000*j-i*j == 500000) return i*j*(1000-i-j);
}
}
}
string str="73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557668966489504452445231617318564030987111217223831136222989342338030813533627661 ...
long tmpA=0,tmpB=0;
for(int i=1; i<=100; i++){
tmpA += i*i;
tmpB +=i;
}
cout << tmpB*tmpB - tmpA <<endl;
#include <iostream>
#include <windows.h>
#include <math.h>
#include <algorithm>
using namespace std;
bool isZs(long num) {
if(num < 2) return false;
for (int i = 2; i <= sqrt(num); i++) {
if ((num % i) == 0)
return false;
}
return true;
}
...
“回文数从两边读值是一样的。两个两位数乘积的最大回文数是9009=91*99,求两个三位数乘积的最大回文数?”
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
using namespace std;
//转成字符串
string num2str(long i){
stringstream ss;
ss <<std::fixed<< i;
return ss.str(); ...
第三题:寻找一个合数的最大质因数对一个数(非质数)进行因数分解,比如13195=5x7x13x29。最大的质因数是29.
那么 600851475143 怎么分解呢?最大的质因数又是多少?
#include <iostream>
#include <list>
#include <math.h>
using namespace std;
int main(){
double n = 600851475143;
list<double> primes;
for(int i=2; i<sqrt(n); i+ ...
用Oauth2.0做认证也有一段时间了,但是总会忘记,整理一下,备忘吧
用户在第三方应用上点击登录,第三方应用通过浏览器跳转,将用户导向认证服务器,同时向服务器传送三个必须的参数:
client_id:必须参数,注册应用时获得的API Key。
response_type:必须参数,此值一般固定为“code”。
redirect_uri:必须参数,授权后要回调的URI,即认证成功后的回跳地址
此时服务器会在session中检测当前用户是否登录
如果已经登录,则检查用户是否对该应用授权
如果已经授权,直接通过浏览器跳转,重新定 ...