Click here to view the problem
/***
Md. Namzul Hasan
Shahjalal University of Science & Technology,Sylhet.
hasan08sust@gmail.com
***/
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define new_line pf("\n")
#define clear_data(array) memset(array,0,sizeof(array))
#define highest_int 2147483647
int main()
{
ll n,m ;
char str[1111],ch ;
ll sum =0 ;
int i ;
while(sc("%s %c %lld",str,&ch,&m)!=-1)
{
if(strcmp(str, "0")==0)
{
pf("0\n") ;
continue ;
}
int len = strlen(str) ;
sum =0 ;
for(i=0 ; i<len ; i++)
{
sum = sum*10 + str[i]-'0' ;
str[i] = sum/m + '0' ;
sum %=m ;
}
if(ch == '%')
{
pf("%lld\n",sum) ;
}
else if(ch =='/')
{
i =0 ;
while(str[i]== '0' && i<len-1)
i++ ;
for( ; i<len ; i++)
pf("%c",str[i]) ;
pf("\n") ;
}
}
return 0;
}
/***
Md. Namzul Hasan
Shahjalal University of Science & Technology,Sylhet.
hasan08sust@gmail.com
***/
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define new_line pf("\n")
#define clear_data(array) memset(array,0,sizeof(array))
#define highest_int 2147483647
int main()
{
ll n,m ;
char str[1111],ch ;
ll sum =0 ;
int i ;
while(sc("%s %c %lld",str,&ch,&m)!=-1)
{
if(strcmp(str, "0")==0)
{
pf("0\n") ;
continue ;
}
int len = strlen(str) ;
sum =0 ;
for(i=0 ; i<len ; i++)
{
sum = sum*10 + str[i]-'0' ;
str[i] = sum/m + '0' ;
sum %=m ;
}
if(ch == '%')
{
pf("%lld\n",sum) ;
}
else if(ch =='/')
{
i =0 ;
while(str[i]== '0' && i<len-1)
i++ ;
for( ; i<len ; i++)
pf("%c",str[i]) ;
pf("\n") ;
}
}
return 0;
}
No comments:
Post a Comment