paste bin
Author
Language
C++
Plain text
Accesslog
Action script
Ada
Apache
Arduino
Armasm
Autohotkey
Awk
Bash
Basic
Brainfuck
C
Clojure
Cmake
C#
css
D
Delphi
Dockerfile
Erlang
Fortran
F#
Gauss
Go
Gradle
Graphql
Groovy
Haskell
Ini
Java
JavaScript
json
Julia
Kotlin
Lasso
LaTeX
Leaf
lisp
llvm
Lua
Makefile
Markdown
Mathematica
Matlab
Nginx
Objective-C
Ocaml
Oxygene
Perl
PgSQL
php
Powershell
Processing
Profile
Properties
Puppet
Purebasic
Python
Q
QML
R
Ruby
Rust
Scala
Scheme
Scilab
Shell
Smalltalk
SQL
Swift
Typescript
VB.NET
VB Script
Verilog
Vim
Wasm
x86asm
Xml
Xquery
Yaml
source code:
#include <cstdio> int f(int target,int *a,int N) { int i,j; if(N==1) return a[0]==target; int *b; bool pr,mr,tr=false; b=new int [N]; for(i=0;i<N;i++) { for(j=0;j<i;j++) b[j]=a[j]; for(j=i+1;j<N;j++) b[j-1]=a[j]; pr=f(target-a[i],b,N-1); mr=f(target+a[i],b,N-1); if(target%a[i]==0) tr=f(target/a[i],b,N-1); if(pr||mr||tr) break; } delete [] b; return pr||mr||tr; } int main(void) { int i,a[5]; bool bf; while(1) { bf=true; for(i=0;i<5;i++) { scanf("%d",a+i); if(a[i]>0) bf=false; } if(bf) break; if(f(23,a,5)==true) printf("Possible\n"); else printf("Impossible\n"); } return 0; }
comment: