Z. Three Numbers – Codeforces Problem Solution in C++

Disclaimer: Make sure you tried enough before checking the solution

Problem: https://codeforces.com/group/MWSDmqGsZm/contest/219432/problem/Z

#include<iostream> 
using namespace std; 
int main() {
	int start,end;
	cin>>start>>end;
	int counter = 0;
	for(int i=0;i<=start;i++){
		for(int z=0;z<=start;z++){
			if(end-i-z>=0 && end-i-z <= start){
				counter++;
			}
		}
	}
	cout<<counter<<endl;
}

Assiut University Training – Newcomers solution

Leave a Comment