MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / main

Function main

Spoj_problems/ACPC10A/solution.cpp:9–25  ·  view source on GitHub ↗

In this problem, we need to find the next sequence of give AP or GP series. If a2-a1 == a3-a2, then its a AP series, otherwise its a GP series. */

Source from the content-addressed store, hash-verified

7 If a2-a1 == a3-a2, then its a AP series, otherwise its a GP series.
8*/
9int main()
10{
11 jaadu;
12 uli a1,a2,a3;
13 cin>>a1>>a2>>a3;
14 while(a1!=0 || a2 !=0 || a3 !=0){ //Loop until the End of input (denoted by 0 0 0)
15
16 if((a2-a1)==(a3-a2)){ //Check for AP Series
17 cout<<"AP "<<a3 + (a3-a2)<<endl; //Print next AP Seq
18 }
19 else{ //GP Series
20 cout<<"GP "<<a3*(a3/a2)<<endl; //Print next GP Seq
21 }
22 cin>>a1>>a2>>a3;
23 }
24 return 0;
25}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected