滴滴的第一题本地用例都通过,而且试了多组,但是提交就是0%

#include <iostream>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
using namespace std;
std::string chengfa(std::string s1, std::string s2)
{     std::string sss(s1.size(), '0');     int temp, temp2, temp3;     for (int kk = 0; kk < s2.size(); kk++)     {         std::string ss;         ss.push_back((s2[s2.size() - 1 - kk] - '0') * (s1[s1.size() - 1] - '0') % 10 + '0');         temp2 = (s2[s2.size() - 1 - kk] - '0') * (s1[s1.size() - 1] - '0') / 10;         for (int i = 1, j = 1; i < s1.size(); i++, j++)         {             ss.push_back(((s2[s2.size() - 1 - kk] - '0')* (s1[s1.size() - i - 1] - '0') + temp2) % 10 + '0');// + ((s2[s2.size() - 1 - kk] - '0') * (s1[s1.size() - i] - '0')) / 10              temp2 = ((s2[s2.size() - 1 - kk] - '0')* (s1[s1.size() - i - 1] - '0') + temp2) / 10;// + ((s2[s2.size() - 1 - kk] - '0') * (s1[s1.size() - i] - '0')) / 10         }         ss.push_back(temp2 + '0');         //std::cout << temp2 << std::endl;         std::reverse(ss.begin(), ss.end());         for (int mm = 0; mm < kk; mm++)             ss.push_back('0');         //std::cout << ss<<std::endl;         temp3 = sss[sss.size() - 1] - '0';         sss[sss.size() - 1] = (temp3 + (ss[ss.size() - 1] - '0')) % 10 + '0';         temp = (temp3 + (ss[ss.size() - 1] - '0')) / 10;         //std::cout << temp << std::endl;         for (int jjk = 1; jjk < sss.size(); jjk++)         {             temp3 = sss[sss.size() - jjk - 1] - '0';             sss[sss.size() - jjk - 1] = (temp3 + ss[ss.size() - jjk - 1] - '0' + temp) % 10 + '0';             temp = (temp3 + ss[ss.size() - jjk - 1] - '0' + temp) / 10;             //    std::cout << temp << std::endl;             //temp = ( sss[sss.size() - jjk-1] - '0' + ss[ss.size() - jjk-1] - '0') / 10;         }         sss.insert(sss.begin(), ss[0] - '0' + temp + '0');         //std::cout << sss << std::endl;     }     if (sss[0] == '0')     {         std::string  str2 = sss.substr(1, sss.size() - 1);         return(str2);     }     else         return(sss);;

}


int main()
{     std::string s1;     int s2;     int k=0;     while (std::cin >> s1>>s2)     {         std::string temp;         for (int i = 0; i < s1.size(); i++)         {             if (s1[i] == '.')                 k = s1.size() - i-1;             else                 temp.push_back(s1[i]);         }                  std::string result = "1";         for (int i = 1; i <= s2; i++)             result = chengfa(result, temp);         if (k!=0)         result.insert(result.size()-k*s2, ".");             std::cout << result<< std::endl;         //std::cout << std::to_string(i);     }     system("pause");
}

先用C++写了个大数乘法的子函数,然后写的主函数,看着是麻烦了点,但是应该没问题,本地用例完全没有问题,但是提交就是0%,导致第二题都没做。

全部评论
第二题没做+1
点赞 回复 分享
发布于 2017-09-23 21:06

相关推荐

11-24 00:11
已编辑
广东工业大学 算法工程师
避雷深圳&nbsp;&nbsp;yidao,试用期&nbsp;6&nbsp;个月。好嘛,试用期还没结束,就直接告诉你尽快找下一家吧,我谢谢您嘞
牛客75408465号:笑死,直属领导和 hr 口径都没统一,各自说了一些离谱的被裁理由,你们能不能认真一点呀,哈哈哈哈哈😅😅😅
点赞 评论 收藏
分享
10-11 17:45
门头沟学院 Java
走吗:别怕 我以前也是这么认为 虽然一面就挂 但是颇有收获!
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务