Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int a[105];
- int main()
- {
- int t,i,j,n,k,l,b,c;
- cin>>t;
- for(l=1; l<=t; l++)
- {
- cin>>n;
- memset(a,0,sizeof(a));
- for(i=2; i<=n; i++)
- {
- b=i;
- j=2;
- while(b!=1)
- {
- while(b%j==0)
- {
- a[j]++;
- b/=j;
- }
- j++;
- }
- }
- cout<<"Case "<<l<<": "<<n<<" = ";
- int flag=0;
- for(i=2;i<=n;i++)
- {
- if(a[i])
- {
- if(!flag)
- {
- cout<<i<<" ("<<a[i]<<")";
- flag=1;
- }
- else
- {
- cout<<" * "<<i<<" ("<<a[i]<<")";
- }
- }
- }
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement