結果
| 問題 | 
                            No.3331 Consecutive Cubic Sum
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2025-11-02 23:25:38 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,251 bytes | 
| コンパイル時間 | 1,432 ms | 
| コンパイル使用メモリ | 167,752 KB | 
| 実行使用メモリ | 16,076 KB | 
| 最終ジャッジ日時 | 2025-11-02 23:25:46 | 
| 合計ジャッジ時間 | 8,330 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 3 TLE * 1 -- * 43 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:84:33: warning: ‘y’ may be used uninitialized [-Wmaybe-uninitialized]
   84 |                                 if(y>=xx && xx!=0) a.push_back(P(xx,y));
      |                                 ^~
main.cpp:72:38: note: ‘y’ was declared here
   72 |                                 ll x,y,xx;
      |                                      ^
            
            ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
vector<P> div(ll n){
	vector<P> d;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0 && i<=n/i){
			if((n/i-i)%2==0) d.push_back(P(i,n/i));
		}
	}
	return d;
}
bool is_sqr(ll N) {
    ll r = (ll)floor(sqrt((double)N));
    return r*r==N;
}
int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	ll i,j;
	ll N;
	cin >> N;
	vector<P> v=div(4*N);
	ll m=v.size();
	vector<P> a;
	vector<P> u;
	REP(i,m){
		ll p=(v[i].second+v[i].first)/2;
		ll q=(v[i].second-v[i].first)/2;
			u.push_back(P(p,q));
	}
		REP(i,u.size()){
			ll R=u[i].first;
			ll L=u[i].second;
			if(is_sqr(1+4*R) && is_sqr(1+4*L)){
				ll x,y,xx;
		if((-1+(ll)sqrt(1+4.0*R))%2==0 && (1+(ll)sqrt(1+4.0*L))%2==0){
			x=(1+(ll)sqrt(1+4.0*L))/2;
			y=(-1+(ll)sqrt(1+4.0*R))/2;
			if(y>=x && x!=0) a.push_back(P(x,y));
		}
			if((1-(ll)sqrt(1+4.0*R))%2==0){
			if(1-(ll)sqrt(1+4.0*L)>=0){
				xx=(1-(ll)sqrt(1+4.0*L))/2;
				if(y>=xx && xx!=0) a.push_back(P(xx,y));
			}
		}
			}
		}
	cout << a.size() << endl;
	REP(i,a.size()){
		cout << a[i].first << ' ' << a[i].second << endl;
	}
	return 0;
}