m0_67001348 2022-09-30 17:03 采纳率: 88.9%
浏览 30
已结题

c++未知问题 超级次方问题

#define  _CRT_SECURE_NO_WARNINGS 
#include <iostream>
#include <vector>
using namespace std;
int quickMod(int x, int n);
const int MOD = 10007;
class solution {
public:
    int x;
    vector<int> vc;
    solution(int x,vector<int>& vc) {
        this->x = x;
        this->vc = vc;
    }
};
int superPow(solution& s)
{
    int x = 1;
    for (vector<int>::iterator it = s.vc.end()--;it != s.vc.begin();it--)
    {
        x *= quickMod(s.x, *it)%MOD;
        s.x *= 10;
    }
    return x;
}
int quickMod(int x, int n) {
    if (n == 0)
    {
        return 1;
    }
    else if (n == 1)
    {
        return x;
    }
    else
    {
        int y = quickMod(x, n / 2) % MOD;
        return n % 2 == 0 ? y * y % MOD : y * y * x % MOD;
    }
}
void test(int x) {
    vector<int> vc;
    vc.push_back(1);
    vc.push_back(0);
    solution s(x, vc);
    cout << superPow(s) << endl;
}
void main() {
    int x;
    cin >> x;
    test(x);
    system("pause");
}

有这个问题

img


我就输入了个2

  • 写回答

2条回答 默认 最新

  • orbitgw C++领域新星创作者 2022-09-30 18:45
    关注

    这个是vector爆掉了,再检查一下

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 10月20日
  • 已采纳回答 10月12日
  • 创建了问题 9月30日

悬赏问题

  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂