Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- int max13_1=-1, max13_2=-1, max2_1=-1, max2_2=-1, maxi1=-1, maxi2=-1;
- int n;
- cin>>n;
- int a;
- for(int i=0;i<n;i++){
- cin>>a;
- if(a%26!=0){
- if(a%13==0){
- if(a>max13_1){
- max13_2=max13_1;
- max13_1=a;
- }
- else{
- max13_2=max(max13_2, a);
- }
- }
- else if(a%2==0){
- if(a>max2_1){
- max2_2=max2_1;
- max2_1=a;
- }
- else{
- max2_2=max(max2_2, a);
- }
- }
- else{
- if(a>maxi1){
- maxi2=maxi1;
- maxi1=a;
- }
- else{
- maxi2=max(maxi2, a);
- }
- }
- }
- }
- int ans=-1;
- if(maxi1!=-1 && max13_1!=-1){
- ans=maxi1*max13_1;
- }
- if(maxi1!=-1 && max2_1!=-1){
- ans=max(ans, maxi1*max2_1);
- }
- if(max2_1!=-1 && max2_2!=-1){
- ans=max(ans, max2_1*max2_2);
- }
- if(max13_1!=-1 && max13_2!=-1){
- ans=max(ans, max13_1*max13_2);
- }
- if(maxi1!=-1 && maxi2!=-1){
- ans=max(ans, maxi1*maxi2);
- }
- int R;
- cin>>R;
- cout<<"Вычисленное контрольное значение: "<<ans<<'\n';
- if(R==ans){
- cout<<"Контроль пройден";
- }
- else{
- cout<<"Контроль не пройден";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement