Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new solution to choco sticks problem #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Choco Sticks and there distribution/ solution_in_c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include<stdio.h>
#include<math.h>
int main() {
int yatin,sahil,store;
int cases;
scanf("%d",&cases);
int i,j;
for(i=0;i<cases;i++)
{
yatin=0;sahil=0;store=0;
int n;
scanf("%d",&n);
int box[n];
for(j=0;j<n;j++)
{
scanf("%d",&box[j]);
if(box[j]%7==0) yatin+=box[j];
else if(box[j]%5==0) sahil+=box[j];
else store+=box[j];
}
// if store has value greater than their difference and after adding store to thier difference if we get an even value surely we can distribute it among two of them..

if(((yatin-sahil)+store)%2==0&&(abs(yatin-sahil)<=store)) printf("true\n");
else printf("false\n");

}
}