hdoj 4432 Sum of divisors
2013-10-11 15:33
295 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4432
解题思路:简单的进制转换
解题思路:简单的进制转换
/************************************************************************** user_id: SCNU20102200088 problem_id: hdoj 4432 problem_name: Sum of divisors **************************************************************************/ #include <algorithm> #include <iostream> #include <iterator> #include <iomanip> #include <sstream> #include <fstream> #include <cstring> #include <cstdlib> #include <climits> #include <bitset> #include <string> #include <vector> #include <cstdio> #include <cctype> #include <ctime> #include <cmath> #include <queue> #include <stack> #include <list> #include <set> #include <map> using namespace std; //线段树 #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 //手工扩展栈 #pragma comment(linker,"/STACK:102400000,102400000") const double EPS=1e-9; const double PI=acos(-1.0); const double E=2.7182818284590452353602874713526; //自然对数底数 const double R=0.5772156649015328606065120900824; //欧拉常数:(1+1/2+...+1/n)-ln(n) const int x4[]={-1,0,1,0}; const int y4[]={0,1,0,-1}; const int x8[]={-1,-1,0,1,1,1,0,-1}; const int y8[]={0,1,1,1,0,-1,-1,-1}; typedef long long LL; typedef int T; T max(T a,T b){ return a>b? a:b; } T min(T a,T b){ return a<b? a:b; } T gcd(T a,T b){ return b==0? a:gcd(b,a%b); } T lcm(T a,T b){ return a/gcd(a,b)*b; } /////////////////////////////////////////////////////////////////////////// //Add Code: /////////////////////////////////////////////////////////////////////////// int main(){ std::ios::sync_with_stdio(false); //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); /////////////////////////////////////////////////////////////////////// //Add Code: int n,m,i,a[16]; char ch[17]="0123456789ABCDEF"; for(i=0;i<16;i++) a[i]=i*i; while(scanf("%d%d",&n,&m)!=EOF){ int ans=0; for(i=1;i<=sqrt(n+0.0);i++){ if(n%i==0){ int x=i,y=n/i; while(x){ ans+=a[x%m]; x/=m; } if(i!=y){ while(y){ ans+=a[y%m]; y/=m; } } } } int num=0,res[1000]; while(ans){ res[num++]=ans%m; ans/=m; } for(i=num-1;i>=0;i--) printf("%c",ch[res[i]]); printf("\n"); } /////////////////////////////////////////////////////////////////////// return 0; } /************************************************************************** Testcase: Input: 10 2 30 5 Output: 110 112 **************************************************************************/
相关文章推荐
- B - Sum of divisors HDU - 4432
- HUD 4432 Sum of divisors 天津现场赛B题
- hdu 4432 Sum of divisors
- HDU 4432 Sum of divisors (进制模拟)
- HDU 4432 Sum of divisors (进制模拟)
- HDU 4432 Sum of divisors
- HDOJ4432 Sum of divisors(暴力)
- HDU 4432 Sum of divisors 质因数分解
- HDOJ4432 Sum of divisors(暴力)
- HDU 4432 Sum of divisors (进制模拟)
- HDU 4432 Sum of divisors 2012 Asia Tianjin Regional Contest
- HDU 4432 Sum of divisors (水题,进制转换)
- HDU-4432-Sum of divisors ( 2012 Asia Tianjin Regional Contest )
- HDU 4432 Sum of divisors
- HDU-4432-Sum of divisors ( 2012 Asia Tianjin Regional Contest )
- [hdu4432]Sum of divisors
- hdu 4432 Sum of divisors(模拟)
- 2017 Multi-University Training Contest 4 && HDOJ 6069 Counting Divisors 【区间筛法】
- Sum of divisors
- hdu 4432 Sum of divisors