zoukankan      html  css  js  c++  java
  • HDU4554 叛逆的小明 水题

      题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4554

      本来是拿这题的FB的,结果脑残把变量命敲错了,wa一次。。。。

     1 //STATUS:C++_AC_0MS_228KB
     2 #include <functional>
     3 #include <algorithm>
     4 #include <iostream>
     5 //#include <ext/rope>
     6 #include <fstream>
     7 #include <sstream>
     8 #include <iomanip>
     9 #include <numeric>
    10 #include <cstring>
    11 #include <cassert>
    12 #include <cstdio>
    13 #include <string>
    14 #include <vector>
    15 #include <bitset>
    16 #include <queue>
    17 #include <stack>
    18 #include <cmath>
    19 #include <ctime>
    20 #include <list>
    21 #include <set>
    22 #include <map>
    23 using namespace std;
    24 //define
    25 #define pii pair<int,int>
    26 #define mem(a,b) memset(a,b,sizeof(a))
    27 #define lson l,mid,rt<<1
    28 #define rson mid+1,r,rt<<1|1
    29 #define PI acos(-1.0)
    30 //typedef
    31 typedef __int64 LL;
    32 typedef unsigned __int64 ULL;
    33 //const
    34 const int N=1000010;
    35 const int INF=0x3f3f3f3f;
    36 const int MOD=256,STA=8000010;
    37 const LL LNF=1LL<<60;
    38 const double EPS=1e-8;
    39 const double OO=1e15;
    40 const int dx[4]={-1,0,1,0};
    41 const int dy[4]={0,1,0,-1};
    42 const int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    43 //Daily Use ...
    44 inline int sign(double x){return (x>EPS)-(x<-EPS);}
    45 template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
    46 template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
    47 template<class T> inline T Min(T a,T b){return a<b?a:b;}
    48 template<class T> inline T Max(T a,T b){return a>b?a:b;}
    49 template<class T> inline T Min(T a,T b,T c){return min(min(a, b),c);}
    50 template<class T> inline T Max(T a,T b,T c){return max(max(a, b),c);}
    51 template<class T> inline T Min(T a,T b,T c,T d){return min(min(a, b),min(c,d));}
    52 template<class T> inline T Max(T a,T b,T c,T d){return max(max(a, b),max(c,d));}
    53 //End
    54 
    55 LL phi[N],f[N];
    56 int n;
    57 
    58 void phitable(int n)
    59 {
    60     int i,j;
    61     for(i=0;i<=n;i++)phi[i]=0;
    62     phi[1]=1;
    63     for(i=2;i<=n;i++)if(!phi[i]){
    64         for(j=i;j<=n;j+=i){
    65             if(!phi[j])phi[j]=j;
    66             phi[j]=phi[j]/i*(i-1);
    67         }
    68     }
    69 }
    70 
    71 int main()
    72 {
    73  //   freopen("in.txt","r",stdin);
    74     int i,j,m=N-9;
    75     phitable(m);
    76     f[1]=2;
    77     for(i=2;i<=m;i++)
    78         f[i]=f[i-1]+phi[i];
    79     for(i=1;i<=m;i++)
    80         f[i]+=f[i]-1;
    81     while(~scanf("%d",&n))
    82     {
    83         printf("%I64d\n",f[n]);
    84     }
    85     return 0;
    86 }
  • 相关阅读:
    Leetcode Binary Tree Level Order Traversal
    Leetcode Symmetric Tree
    Leetcode Same Tree
    Leetcode Unique Paths
    Leetcode Populating Next Right Pointers in Each Node
    Leetcode Maximum Depth of Binary Tree
    Leetcode Minimum Path Sum
    Leetcode Merge Two Sorted Lists
    Leetcode Climbing Stairs
    Leetcode Triangle
  • 原文地址:https://www.cnblogs.com/zhsl/p/3090548.html
Copyright © 2011-2022 走看看