Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- using namespace std;
- int main()
- {
- int n,k;
- int num[120];
- memset( num , 0 , 120) ;
- for(int u=0;u<120;u++)
- num[u]=0;
- while(cin>>n>>k)
- {
- for(int u=20;u<n+1;u++)
- {
- num[0]+=1/u;
- int lop=0,temp=1;
- while(temp<u)
- { temp*=10;
- lop++;
- }
- while(temp!=0&&lop!=k+2&&u!=1)
- {
- while(temp<u)
- { temp*=10;
- lop++;
- }
- num[lop]+=temp/u;
- temp=temp%u;
- // lop++;
- }
- }
- for(int u=k+1;u>0;u--)
- while(num[u]>9)
- {
- num[u-1]+=1;
- num[u]-=10;
- }
- cout<<num[0]<<".";
- for(int u=1;u<k+1;u++)
- cout<<num[u]<<" ";
- cout<<"\n";
- for(int u=0;u<k+1;u++)
- num[u]=0;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment