2 条题解

  • 2
    @ 2025-12-24 19:50:13
    #include<bits/stdc++.h>
    using namespace std;
    #define int long long
    signed main()
    {
    	int n;cin>>n;
    	vector<int>G;
    	for(int l=1,r=0;l<=n;l=r+1)
    	{
    		r=n/(n/l);
    		G.push_back(r);
    	}
    	cout<<G.size()<<'\n';
    	for(int y:G)cout<<y<<' ';
    	return 0;
    }
    • 0
      @ 2026-8-3 15:05:39

      经典除法分块加速问题

      不会的去看 模板 。一模一样!!!

      #include<bits/stdc++.h>
      #define int long long
      using namespace std;
      int n;
      vector<int>a;
      signed main(){
      	ios::sync_with_stdio(false);
      	cin.tie(0),cout.tie(0);
          cin>>n;
          for(int l=1,r;l<=n;l=r+1){
          	a.emplace_back(n/l);
              r=n/(n/l);
          }
          cout<<a.size()<<"\n";
          for(auto i=a.rbegin();i!=a.rend();i++)
          	cout<<*i<<" ";
          return 0;
      }
      
      • @ 2026-8-3 15:08:34

        kevin的更短,更好

    • 1

    信息

    ID
    3249
    时间
    1000ms
    内存
    1024MiB
    难度
    6
    标签
    递交数
    41
    已通过
    12
    上传者