首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
HKX9XAS
2026年3月22日 17:16
最长连续因子 题解:优化至O(n/2)的时间复杂度
P1020
回复 0
|
赞 2
|
浏览 141
#include<stdio.h> #include<iostream> using namespace std; int main(){ int n; while(cin>>n){ int mxlen=1; int max_last_pos = n; &nb...
HKX9XAS
2026年3月20日 21:32
最长连续因子 题解:结构体存储连续因子数组及其长度
P1020
回复 0
|
赞 2
|
浏览 125
#include<stdio.h> #include<iostream> #include<string> #include<vector> using namespace std; struct Lian{ int len; vector<int> facs; }; int main(){ int n; vector<int>...
yauqq
2026年3月18日 14:54
最长连续因子 题解:
P1020
回复 1
|
赞 19
|
浏览 275
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int len = 0,maxlen = 0,pos = 2; for(int i = 2;i <= n;i++){ if(n % i == 0){ len++; if(maxlen < len){ maxlen = len; pos = i; } } else len = 0; } for(i...
ccc00008
2026年3月19日 16:08
最长连续因子 题解:
P1020
回复 0
|
赞 2
|
浏览 117
#include<iostream> using namespace std; #include <string> #include <vector> #include <map> #include<algorithm> void SaveToMap(vector<int> &temp,map<int,vector<int>> &MP,int &curMax){ if (temp.empty()) return; MP.insert(pair...
2488048091
2026年3月16日 17:56
最长连续因子 题解:
P1020
回复 0
|
赞 2
|
浏览 189
#include<iostream> #include<vector> using namespace std; //map<type1,type2> mapname; int main() { int N; cin>>N; vector<vector<int> > ans; vector<in...
2488048091
2026年3月16日 17:56
最长连续因子 题解:
P1020
回复 0
|
赞 0
|
浏览 109
#include<iostream> #include<vector> using namespace std; //map<type1,type2> mapname; int main() { int N; cin>>N; vector<vector<int> > ans; vector<in...
彻底死去
2026年3月16日 17:01
最长连续因子 题解:
P1020
回复 0
|
赞 2
|
浏览 126
//暴力 #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<string> #include<cstring> using namespace std; int main() { int n; cin >> n; int best_seq[1000] = { 0 }; int curr_seq[1000] = { 0 }; ...
太一
2026年3月15日 23:51
最长连续因子 题解:
P1020
回复 0
|
赞 1
|
浏览 154
#include<iostream> #include<cmath> #include<algorithm> #include<string> using namespace std; int main() { int n, arr[10000] = { 0 }, sum = 0, index = 0, brr[10000] = { 0 }, Max = 0, crr[10000], num = 0; cin >> n; &...
sky952
2026年3月15日 15:18
最长连续因子(c语言)题解:
P1020
回复 0
|
赞 4
|
浏览 143
从i(2<=i<=N)开始检查i,i+1,i+2..... 如果N%j==0,继续直到不满足停止 每次记录下当前长度,最长长度,以及起点,如何当前长度大于最长长度,那就更新最长长度以及起点 最终从起点依次输出就行。 #include <stdio.h> int main() { int N; scanf("%d", &N); int max_len = 0; int start = ...
bububu
2026年3月5日 11:34
最长连续因子 题解:
P1020
回复 1
|
赞 26
|
浏览 492
一种基于数组存储的思想 #include <stdio.h> int main() { int num = 0; int i = 0; int dig[10000] = {0}; int j = 0; scanf("%d", &num); // 1. 找出所有因子,但不包括1 ...
1
2
3
...
7
题目
最长连续因子
题解数量
66
发布题解
在线答疑
热门题解
1
最长连续因子 题解:纯C
2
最长连续因子 题解:使用一个长度量时刻记录,同时不停与最长变量对比
3
最长连续因子(贪心) 题解:
4
最长连续因子 题解:c
5
最长连续因子 题解:测试数据有问题,可以偷AC
6
最长连续因子 题解:
7
最长连续因子 题解:
8
最长连续因子 题解:不用数组,我感觉还是好理解的
9
最长连续因子 题解:
10
最长连续因子 题解:纯C语言