zoukankan      html  css  js  c++  java
  • cf 1062d 思维 欧拉筛变形

    http://codeforces.com/contest/1062/problem/D

    题意:给个n ,在n之内 所有(a,b) ,如果存在唯一的x 使a*|x| == b 或者 b* |x| == a   (a,b>2)那么ans + |x| 求最后结果

    思路:如果a%b==0那么肯定是唯一的x了,枚举(a,b)加上他们的商就好了

       枚举的(a,b)的时候 ,用欧拉筛的思想,第二重用a的倍数来枚举...

    #include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define pb push_back
    #define mp make_pair
    #define pii pair<int,int>
    #define all(v) v.begin(),v.end()
    
    const int N = 1e4+4;
    const int INF = 1E9+4;
    const ll mod = 1e9+7;
    
    int n,m;
    int a[N],b[N];
    vector<int>p;
    vector<int>V[1000004];
    
    int main(){
    
        ios::sync_with_stdio(false);
        cin.tie(0);
    
        cin>>n;
        ll ans = 0;
        for(int i=2;i<=n;++i){
            for(int j = i+i;j<=n;j+=i){
                ans += j/i;
            }
        }
        cout<<ans*4<<endl;
        return 0;
    }
  • 相关阅读:
    瀑布流
    进度条
    图片延迟加载、scroll
    scroll 滚动广告
    json
    样式更改
    js 不同浏览器的宽度获取
    孤立点挖掘算法
    数据结构算法代码
    深入浅出JMS(一)--JMS基本概念
  • 原文地址:https://www.cnblogs.com/wjhstudy/p/9986106.html
Copyright © 2011-2022 走看看