/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 5ms 564.0 KiB
#3 Accepted 15ms 532.0 KiB
#4 Accepted 29ms 564.0 KiB
#5 Accepted 54ms 556.0 KiB
#6 Accepted 85ms 532.0 KiB
#7 Accepted 119ms 564.0 KiB
#8 Accepted 2ms 532.0 KiB
#9 Accepted 2ms 532.0 KiB
#10 Accepted 3ms 352.0 KiB
#11 Accepted 8ms 532.0 KiB
#12 Accepted 122ms 568.0 KiB
#13 Accepted 1ms 532.0 KiB
#14 Accepted 1ms 532.0 KiB
#15 Accepted 1ms 532.0 KiB
#16 Accepted 1ms 532.0 KiB
#17 Accepted 4ms 532.0 KiB
#18 Accepted 5ms 572.0 KiB
#19 Accepted 4ms 532.0 KiB
#20 Accepted 4ms 532.0 KiB
#21 Accepted 4ms 324.0 KiB

Code

/**
 Author : Kamonasish Roy (Bullet)
 Time : 2025-02-25 13:03:09
 **/

#include<bits/stdc++.h>
using namespace std;
const long long M=5e5,MOD=1e9+7;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
   // cin>>t;
    while(t--){
    	int x;
    	cin>>x;
    	assert(x>=1 && x<=1000);
    	vector<int>p(1002,1);
    	for(int i=2;i<=1000;i++)p[i]=i;
    	for(int i=2;i<=1000;i++){
    		if(p[i]==i){
    			for(int j=i*i;j<=1000;j+=i)p[j]=i;
    		}
    	}
    	int cnt=0;
    	for(int i=1;i<x;i++){
    		for(int j=1;j<x;j++){
    			if(i+j>x)break;
    			for(int k=1;k<x;k++){
    				if(i+j+k>x)break;
    				cnt+=(p[i+j+k]==i+j+k);
    			}
    		}
    	}
    	cout<<cnt<<"\n";
    	
    	
    	
    	}
    	
    	   
    return 0;
 
}

Information

Submit By
Type
Submission
Problem
P1172 Counting Triplets
Contest
Lu IEEE testing round
Language
C++17 (G++ 13.2.0)
Submit At
2025-02-25 09:06:27
Judged At
2025-02-25 09:06:27
Judged By
Score
100
Total Time
122ms
Peak Memory
572.0 KiB