Difference in execution time in C and C++

前端 未结 2 1642
Happy的楠姐
Happy的楠姐 2021-01-05 06:37

I recently found this site called codechef, where you can submit solutions to problems. I had submitted two answers for a question, one in C and the other in C++. Both codes

2条回答
  •  自闭症患者
    2021-01-05 07:06

    I usually add these 3 lines in my code just after the main() for faster input output :

    ios_base::sync_with_stdio(false);
    
    cin.tie(NULL);
    
    cout.tie(NULL);
    

    So , Try this :

    int main()  
    {
       ios_base::sync_with_stdio(false);
       cin.tie(NULL);
       cout.tie(NULL);
       int n, k, t,num=0;
       cin>>n>>k;
       for(int i=0;i>t;
         if(t%k==0)  num++;
       }
    
       cout<

提交回复
热议问题